javajmsmessage-driven-bean

Configuring an MDB to listen to multiple queues


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?


Solution

  • 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.