Configuring an MDB to listen to multiple queues

Ittai picture Ittai · May 4, 2011 · Viewed 7.9k times · Source

I'm using EJB 3.1 and I want to configure an MDB to listen to multiple queues.
I'd prefer defining the queue names via XML but the other definitions via annotations.
Can this be done?

Answer

jpredham picture jpredham · Aug 24, 2011

Once instantiated, an MDB can only listen to the resource specified in their destination ActivationConfigProperty, however you can create multiple instances of the same MDB with different destinations (queues, in your case).

Create two entries in your ejb-jar.xml with different destination and ejb-name properties, but the same ejb-class.