2 Replies Latest reply on Jan 17, 2003 6:47 PM by Elias Ross

    Can a MDB be suspend & resume itself?

    Paul Bandler Newbie

      I would like to be able to create a MDB that suspends and resumes delivery of messages to its onMessage call-back - can this be achieved?

      I notice that the Connection interface has a stop and start method but normally an MDB doesn't have access to the 'connection' that I assume exists within JBoss between an MDB and the destination that it serves. Is there a way to access and manipulate this connection object from the MDB?

      Thanks in anticipation,

      Paul Bandler

        • 1. Re: Can a MDB be suspend & resume itself?
          Ulf Schroeter Novice

          How should an MDB reactivate itself after self-deactivation ( which might be technically possible with some tedious MBean code )? There has to be some other external monitor/stimulus for that !

          • 2. Re: Can a MDB be suspend & resume itself?
            Elias Ross Master

            Take a look at somebody's message here:

            http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ the source to JBoss and craft yourself an Invoker subclass.

            See the classes:

            Invocation.getArguments() returns an array of one object,
            the first is the javax.jms.Message going to your MDB.
            You can decide to hold on to the message, or redirect it to another queue, like the dead letter service. Remember that you're going to be affecting all JMS messages.

            Probably even better: If you want to suspend message delivery, you can easily call stopService on the MDB using the "jmx-console", and then startService to being receiving the messages again.

            There are lots of ways of doing this.