0

I am using Solace queue and reading messages from the queue. The messages in the queue having versions because I am working in multithreaded env. and with multiple instances, so it is quite possible that application would read the messages without sequence.

So, I need a solution for that so I can process the message in sequence only. Example: Message1 version are 1, 2, 3, 4......so on. Message2 version are 1, 2, 3, 4......so on.

Note: We are stroing messages in db so previous version we can get from DB.

Condition:- if some instance is picking Message1 and Version 1 and some other instance is picking version 3 of same message, so version 1 would process first and application should be smart enough to wait for version 2, then processed for version 3. If version 2 never come so there should be some timeout and version 3 would be discarded.

Note: It’s a real time message processing application so performance also matters.

I was thinking to implement some in-memory hash map, that would store the messages in HashMap if currentVersion != previousVersion+1, if we receive the previousVersion+1 then check the HashMap again and process the next version if that HashMap contains it. But problem is that we have multiple JVMs, so this approach would not work. Please let me know if anyone has any better approach to achieve this.

0 Answers0