6 Replies Latest reply on Dec 17, 2008 10:24 AM by pbaker01

    Stopping an MDB from Listening to a Queue

    pbaker01

      I have posted this question on a few different forums... So I apologize again for the cross posting.

      Most recent at: JBoss.com -> JBoss User -> JBoss Messaging
      http://www.jboss.com/index.html?module=bb&op=viewtopic&t=147381
      And I have been referred to this forum.

      Problem:
      I have a queue and a listener. The listener is configured as a MDB. I want to be able to:
      o Start/Stop the queue delivery via JMX
      o Start/Stop the queue delivery programatically

      I have seen several posts that suggest that I should be able to use JMX to "stopDelivery". When I look at my JMX console page I do not see any reference to my MDB and certanly no references to stopDelivery. I have deployed the application via Eclipse as "Exploded".

      Environment:
      JBoss: Jboss-5.0.0 GA
      JDK: jdk1.6.0_10

      Below is the code for my MDB:

      import javax.ejb.ActivationConfigProperty;
      import javax.ejb.MessageDriven;
      import javax.jms.JMSException;
      import javax.jms.Message;
      import javax.jms.MessageListener;
      import javax.jms.TextMessage;
      
      @MessageDriven(mappedName = "jms/SSMListener", activationConfig = {
       @ActivationConfigProperty(propertyName="messagingType", propertyValue="javax.jms.MessageListener"),
       @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
       @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
       @ActivationConfigProperty(propertyName="destination",propertyValue="queue/SSMQueue") })
      public class SSMListener implements MessageListener {
      
       public void onMessage(Message arg0) {
       // TODO Auto-generated method stub
       TextMessage tm = (TextMessage) arg0;
       try {
       System.out.println("I'm alive - " + tm.getText());
       } catch (JMSException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
       }
       }
      }


      JBoss.xml
      <jboss>
       <enterprise-beans>
       <message-driven>
       <ejb-name>SSMListener</ejb-name>
       <local-jndi-name>jms/SSMListener</local-jndi-name>
       <destination-jndi-name>queue/SSMQueue</destination-jndi-name>
       </message-driven>
       </enterprise-beans>
      </jboss>


      destinations-service.xml
      <mbean code="org.jboss.mq.server.jmx.Queue"
       name="jboss.mq.destination:service=Queue,name=SSMQueue">
       <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
       </mbean>


      Here is are two snapshots of my JMX console.

      http://img.picbite.com/2008/12/14/22833fjhhs.png
      http://img.picbite.com/2008/12/14/22835imemm.png

      I don't see any JMX controls for startDelivery or stopDelivery.
      o What am I doing wrong here?
      o Do I need to configure the MDB as an mbean?

      For start/stoping programatically I have the following code:
      ObjectName objectName;
      try {
       objectName = new ObjectName(
       "jboss.j2ee:binding=message-driven-bean, jndiName=jms/SSMListener, plugin=invoker,service=EJB");
       MBeanServer server = MBeanServerLocator.locateJBoss();
       server.invoke(objectName, "stopDelivery", new Object[] {}, null);
      } catch (MalformedObjectNameException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
      } catch (NullPointerException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
      } catch (InstanceNotFoundException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
      } catch (MBeanException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
      } catch (ReflectionException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
      }


      This code generates exception:
      10:55:55,157 ERROR [STDERR] javax.management.InstanceNotFoundException: jboss.j2ee:binding=message-driven-bean, jndiName=jms/SSMListener, plugin=invoker,service=EJB is not registered.
      10:55:55,158 ERROR [STDERR] at org.jboss.mx.server.registry.BasicMBeanRegistry.get(BasicMBeanRegistry.java:529)
      10:55:55,158 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:662)
      10:55:55,158 ERROR [STDERR] at com.sita.wab.service.SsimService.startLoad(SsimService.java:65)
      10:55:55,158 ERROR [STDERR] at com.sita.wab.ejb.ssim.SsimEjbBean.startLoad(SsimEjbBean.java:32)


      I suspect once I get the JMX issue resolved the answer to this problem will be obvious.

      Other than the starting/stopping the queue, everything else works well.

      Any help will be greatly appreciated.

      And again, I apologize again for the cross posting. Hopefully the answer will be found here :)

      Paul


        • 1. Re: Stopping an MDB from Listening to a Queue
          clebert.suconic

          Man...

          You are really cross posting. I know you realized that...

          I already told you how to stop a MDB. You just stop the EAR where your MDB is located at.


          Your question now is more specific to "how to stop a specific component". (maybe after some investigation of course).

          Instead of asking the same question again, if you asked something specific, you would get an answer faster.


          • 2. Re: Stopping an MDB from Listening to a Queue
            pbaker01

            Hi again Clebert,

            Thank you for the reply. Starting/Stoping the EAR is not the solution that I
            am looking for. However, that said, perhaps you are correct. I should
            focus on the basic problem and that is how to expose the startDelivery
            and stopDelivery methods in JMX.

            I want to configure my app so that my MDB is exposed as a service along
            with the startDelivery and stopDelivery methods. What am I missing?

            No more cross posts, I promise! :)

            Paul




            • 3. Re: Stopping an MDB from Listening to a Queue
              clebert.suconic

              Ok...


              Now I have a question:


              With JBoss4 I used to be able to call StopDelivery directly on the MDB. All I had to do is find the MDB MBean, usually with a name like:

              binding=message-driven-bean,jndiName=local/MDBExample@1421788223,plugin=invoker,service=EJB


              This is actually documented on the JBAS user's guide.


              But with JBoss5 this is not available.



              If this was not disabled by design (with a strong reason for that):


              That would probably be considered a bug.

              • 4. Re: Stopping an MDB from Listening to a Queue
                pbaker01

                Clebert,

                Thanks for following up on this.. I do think that I have a configuration
                problem though because even with Joss4 I did not have the
                start/stopDelivery methods shown on the MDB within the JMX console.

                I do think that we have narrowed down my problem to:

                - Is there any special configuration required to expose the start/stopDelivery methods for an MDB for JMX?
                - Under what conditions are these methods shown in JMX and what would prevent them from being shown?

                PB - Atlanta



                • 5. Re: Stopping an MDB from Listening to a Queue
                  pbaker01

                  I have fallen back to JBoss 4.2.3.

                  Using the http://localhost:8080/jmx-console/
                  I search for jboss.j2ee and locate my MDB
                  jar=WAB_EJB.jar,name=SSMListener,service=EJB3

                  When I select the MDB link it I get controls to start and stop the MDB. Refer to the
                  images here: http://picbite.com/image/11176bjgfn/

                  Two points:
                  1) I don't find any JMX entry that is formatted like that described above by Clebert:
                  binding=message-driven-bean,jndiName=local/MDBExample@1421788223,plugin=invoker,service=EJB
                  2) I can't find equivalent control using JBoss 5.

                  I know that I am missing something... What is it?
                  Any help will be appreciated.

                  Paul

                  • 6. Re: Stopping an MDB from Listening to a Queue
                    pbaker01

                    Anybody?

                    I have seen at least one other unanswered topic regarding this issue:
                    http://www.jboss.com/index.html?module=bb&op=viewtopic&t=133360

                    Any guidance would be greatly appreciated.

                    PB