3 Replies Latest reply on Apr 5, 2013 9:20 AM by Andy Taylor

    How to use wildcards with MDB's (on AS 7.1.3 and later)

    Marco Rietveld Novice

      What I would like to do is create an message driven bean (MDB) that listens to multiple queues: in order to do this, I thought I'd use the wildcard syntax that hornetq provides.

       

      In essence, I'm creating an application which users will configure by adding their own "domains". Users can then configure the AS to add their own domain queues (like JBPM.TASK.DOMAIN.MINE, etc.) and I need a way to have my MDB pick up messages from whichever queues they might create. However, they might also decide that separate queues aren't necessary, and want to only use the (basic) JBPM.TASK queue.

       

      The top of my MDB:

       

      @MessageDriven(activationConfig = {

              @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),

              @ActivationConfigProperty(propertyName = "destination", propertyValue = "java:/queue/JBPM.TASK.#") },

              name = "TaskMDB")

      public class TaskMessageBean implements MessageListener {

       

      Note the '#' at the end of the queue name.

       

      See the attached file (used for deploying queues to AS 7.x) for an example of the queues that I'd use it with: in short, I'd like the MDB to receive messages from JBPM.TASK and JBPM.TASK.DOMAIN.TEST (among others).

       

      When I test with jboss 7.1.1 (or 7.1.3), using the standalone-full profile, I see the following log. This makes me think that the wildcard is being literally interpreted.

       

      21:00:29,388 INFO  [org.jboss.as.server] (management-handler-thread - 4) JBAS018559: Deployed "test-jms.war"

      21:00:31,107 INFO  [org.hornetq.ra.inflow.HornetQActivation] (default-threads - 2) Attempting to reconnect org.hornetq.ra.inflow.HornetQActivationSpec(ra=org.hornetq.ra.HornetQResourceAdapter@609fb8b6 destination=java:/topic/JBPM.TASK.# destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=null maxSession=15)

      21:00:31,107 INFO  [org.hornetq.ra.inflow.HornetQActivation] (default-threads - 1) Attempting to reconnect org.hornetq.ra.inflow.HornetQActivationSpec(ra=org.hornetq.ra.HornetQResourceAdapter@609fb8b6 destination=java:/queue/JBPM.SESSION.# destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=null maxSession=15)

      21:00:31,122 INFO  [org.hornetq.ra.inflow.HornetQActivation] (default-threads - 2) awaiting topic/queue creation java:/topic/JBPM.TASK.#

      21:00:31,124 INFO  [org.hornetq.ra.inflow.HornetQActivation] (default-threads - 1) awaiting topic/queue creation java:/queue/JBPM.SESSION.#

       

      (The "java:/queue/JBPM.SESSION.#" is because of a second similar MDB that's setup to listen to queues whose names begin with JBPM.SESSION)

       

      Thanks in advance!