Question

I have a java class Processor that is listening to a jms topic and it is struggling to keep up with the speed in which messages are arriving so we've decided to go concurrent:

A single class listening to the topic who's job is to hand the messages out to a pool of worker threads, effectively being a load balancer. It also has to prevent 2 workers processing messages for the same customer.

I expected there to be quite a lot of information on the internet about this but everything seems to suggest the use of EJBs where the app server manages the pool and does the balancing. I'm sure this must be a really common problem, but can't seem to find any libraries or design patterns to assist. Am I making more out of it than it is and should just delve in and write my own code?

Was it helpful?

Solution

This is an easy problem to solve with a pool of listeners. That's what the app server would be doing for you.

I'd get a good app server and use its MDBs to solve this quickly. Size the pool to keep up and you'll be fine.

If you insist on writing your own code, get a good open source pool implementation and use it.

If it must be non-EJB, consider Spring. It has message driven POJOs that could be just what you need.

OTHER TIPS

Why don't you just use a queue instead of a topic and have several instances of the same application handle messages from this queue ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top