1 Reply Latest reply on Sep 29, 2005 11:47 AM by dstoleson

    MDB message router pattern vs. multiple source queues

    npdavis

      All,
      JBossMQ works extremely well for our purposes. In fact, it hasn't been touched in months and is happily doing it's thing. Our router pattern has an mdb connected to a mapped queue out to DMZ where our servlets interact with it, firewall, NAT, reverse lookup and all, it works like a champion.

      Now it's time to expand. We are installing a second DMZ at a large ISP. I need to somehow route messages from this dmz as well. I know an MDB queue listener can only consume messages from one queue, per the spec.

      Is there a way to instance an MDB and create a second instance(via configuration?) that watches a different queue, from the same bytecode?

      I am looking for a pointer on the cleanest way to do this. I really don't want to make a second mdb, same code, different name, but if that's the way it's done, cool.

      Any advice would be greatly appreciated 8 ) I don't need a great deal of detail, just a pointer on what I should look for to figure out how to do this the cleanest way possible.

      The way I see it, I either duplicate the router, or create a new type of mdb which does nothing but pull from the dmz's and drop the messages into the router queue (which would now be local), creating in effect, a simple queue aggregation system to consolidate stuff for the router.

      Any help or links about this subject would be greatly appreciated.

      -Neil

        • 1. Re: MDB message router pattern vs. multiple source queues
          dstoleson

          Yes.

          You can configure multiple MDBs, each with a different name in the ejb-jar.xml and jboss.xml file that use the same class.

          Example:

          ejb-jar.xml
          -------------

          <!-- Queue #1 -->
          <message-driven >
          <ejb-name>Foo1</ejb-name>
          <ejb-class>org.foo.FooEJB</ejb-class>
          <transaction-type>Container</transaction-type>
          <acknowledge-mode>Auto-acknowledge</acknowledge-mode>
          <message-driven-destination>
          <destination-type>javax.jms.Queue</destination-type>
          <subscription-durability>NonDurable</subscription-durability>
          </message-driven-destination>
          </message-driven>

          <!-- Queue #2 -->
          <message-driven >
          <ejb-name>Foo2</ejb-name>
          <ejb-class>org.foo.FooEJB</ejb-class>
          <transaction-type>Container</transaction-type>
          <acknowledge-mode>Auto-acknowledge</acknowledge-mode>
          <message-driven-destination>
          <destination-type>javax.jms.Queue</destination-type>
          <subscription-durability>NonDurable</subscription-durability>
          </message-driven-destination>
          </message-driven>

          jboss.xml
          -----------

          <!-- Queue #1 -->
          <message-driven>
          <ejb-name>Foo1</ejb-name>
          <destination-jndi-name>queue/queue1</destination-jndi-name>
          </message-driven>

          <!-- Queue #1 -->
          <message-driven>
          <ejb-name>Foo2</ejb-name>
          <destination-jndi-name>queue/queue2</destination-jndi-name>
          </message-driven>