I have this Java project called Server. Server is essentially a single-threaded application that listens to events from external applications. These events are crucial and missing one is a huge deal.
What Server does is that it listens to events, does some calculations based from the events received, and stores the calculated value in the database. Also, some events are dependent on each other and I have a single static map that keeps track of all the events coming in.
I'm handling call events. There are three events that I'm currently handling:
Join events: Where two people are in a conversation
Talking events: Where either person A or B are talking
Leave events: Where either person leaves the conversation
My goal is to calculate how much time each person talked for the duration of the conversation.
What I do right now is, when I get a Join event, I add that conversation to the map. While I get talking events, I get the conversation from my map and do some calculation. When someone leaves the conversation, I remove the conversation from the map and save whatever I have in the database.
Since I can't afford to miss a single event, how do I implement redundancy? I thought about clustering but if ever I do cluster, then both clusters will have the same events coming in, leading to data duplication.