I have a Java EE message driven bean that needs to listen to multiple queues (9 different queues). I understand that I can define 9 different message beans (one for each unique queue) and just use some common class for the business logic but it seems like there should be a better method. The only alternative I can find is to use the ejb-jar.xml to define the 9 different beans. This seems like a better option however with it comes the problem of the code knowing what its message destination is at run-time. How can this be done? I suppose reflection but is there a better method? Just in case I wasn't clear enough I'm looking to have the same MDB listen to multiple "destination". Here's destination being set via annotation" @ActivationConfigProperty(propertyName = "destination", propertyValue= "queue1")
Asked
Active
Viewed 496 times
0
-
Credit to @JustAnotherProgrammer – Steve C Mar 22 '16 at 12:55
1 Answers
0
You can also create one base MDB without annotations, then 9 different extensions ( with no body ) annotated for each destination, but the XML strategy sounds better. You can determine the destination from the message.
Ideally, you could pick a JMS implementation that supports virtual destinations, like ActiveMQ, where a composite destination fronts multiple physical destinations.

Nicholas
- 15,916
- 4
- 42
- 66