I have a problem where I need to synchronize processing for multiple threads across multiple different servers for a Java service on Windows.
In this application, I have multiple consumer threads pullings messages off the same JMS queue. Messages come in in groups of 3 or 4, and I need to make sure the messages in each group are processed completely in serial. I need some sort of synch mechanism to make sure if thread1 pulls a message off, then thread2 pulls the next message from that group, thread2 waits for thread1 to finish processing before starting to process it's message.
Any suggestions on distributed synching mechanisms for threads? Any type of solution would be good (JMS solutions, distributed caching, etc.)
Note: the JMS provider we're using is ActiveMQ.
Thread Synchronization is a process of allowing only one thread to use the object when multiple threads are trying to use the particular object at the same time. To achieve this Thread Synchronization we have to use a java keyword or modifier called “synchronized”.
ActiveMQ has support for message groups which, quite literally, should be exactly what you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With