4 Replies Latest reply on Dec 15, 2008 10:10 PM by pbaker01

    Starting/Stopping MDB via JMX

    pbaker01

      First I know that the questions below has been asked
      many times. I have seen several posts where the replies say:
      "Search for the Answer". I have searched and I can't find it...

      Note Originally posted JBoss.com -> JBoss User -> Beginners Corner as:
      http://www.jboss.com/index.html?module=bb&op=viewtopic&t=147307

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

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

      I cannot find an answer for either. First the JMX issue

      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.


        • 1. Re: Starting/Stopping MDB via JMX
          clebert.suconic

          You will find a lot of stuff deployed for an EAR on the JMX-console.


          Just look for the correct MBean, and you could stop it.


          For instance, I just stopped the MDB example (from JBossMessaging 1.4.1 SVN) and the stop worked fine.

          The MDB I found was : "module="mdb-example.jar",service=EjbModule". It was under jboss.j2ee module. (You should probably filter it by jboss.j2ee:*)


          Anyway.. this is more a JCA question than JBossMessaging. MDB is a layer in top of JBossMessaging. We just deliver the message to the JCA Layer and the application server deals with deployments / starts / stops... etc.

          • 2. Re: Starting/Stopping MDB via JMX
            pbaker01

            Hi Clebert,
            Thank you for the post. For some reason my MDB is not showing up in
            the JMX console (see the image file that is posted above). I'm doing
            something fundamentally wrong and I'm not sure what. I originally
            posted on the Beginners Corner as I have not used MDB with JBoss and I
            am not that familure with JMX...

            What is the best forum to address this problem? I don't like cross posting
            and I know that the the moderators don't like it either... So I apologize
            in advance... Paul


            • 3. Re: Starting/Stopping MDB via JMX
              clebert.suconic

              Looking at your picture, you would need to stop the whole EAR application, MBean named "ear=WAB_EJB.jar... etc... etc".


              I don't know if it would make sense to stop just one component of an application. I believe there are some security constraints on JBAS.


              If you want to ask how you could stop an individual component out of an EJB3 application You should ask that question on the EJB3 or JCA. As I told you we just deliver the message and test the integration. for specific questions on MDB you should ask the EJB3 guys.

              • 4. Re: Starting/Stopping MDB via JMX
                pbaker01

                Thanks again for you reply...

                This topic has been moved to
                JBoss.com -> JBoss User -> EJB 3.0 as:
                http://www.jboss.com/index.html?module=bb&op=viewtopic&t=147390&start=-10

                Hopefully it is the last stop.