3 Replies Latest reply on Sep 2, 2004 1:18 PM by adrian.brock

    message ordering in MDB from queue

    parkenf

      Hi

      I've got an application design problem:
      I have an (arbitrary) number of clients calling (synchronously) methods on a stateless session bean. I want to release these clients quickly, by using JMS, without seriously compromising the total execute time of all these calls. I have written this so that the clients post an "invoke" message to a queue. This is read by an MDB, and used to invoke the relevant method on the SSB.

      My problem is that although messages are being read from the queue in the correct order (I presume), there is no subsequent control to ensure that the methods on the SSB are executed in the same order. When using only one client I could fix this by using the "Singleton Message Driven Bean" configuration, but this is not suitable when more than one client is writing.

      As far as I can see I have 3 options
      (1) require a 1-1 mapping between clients and mdb-deployments, each mdb jar would contain the same MDB (with the "Singleton" config) reading the same queue but using a different message selector, to which the client could publish: this enforces a dedicated consumer for each publisher.
      (2) put something into the invoker stack for the MDB to order messages by publisher - not sure how you'd do this
      (3) write order numbers into my publisher, and then write wait-notify-wait-etc logic into my MDB - nasty

      anyone got any better ideas?

      Neil

        • 1. Re: message ordering in MDB from queue

          We do not answer design questions here. Only technical questions.

          If you want help with design, hire a consultant.

          • 2. Re: message ordering in MDB from queue
            parkenf

            I trust you'll forgive my imposition. I have seen many questions in this forum about the use of the singleton configuration, and I consider this a variant on the theme. Perhaps you can answer my jboss specific question:

            Is it possible to intercept a message when it is being pulled off a queue before the MDBs get to it, by placing a custom interceptor in the stack. How might this be done?

            • 3. Re: message ordering in MDB from queue

              Just create your own message driven bean container-configuration
              that includes the interceptor and reference it from your mdb in META-INF/jboss.xml

              Or even simpler, modify the standard container in conf/standardjboss.xml

              More portably, change your mdb into a something that implements the
              chain of responsibilty pattern.