7 Replies Latest reply on Jan 8, 2013 11:01 AM by chmanosh

    Programmatic way to control ESB listener from action pipeline?

    dbuttery

      Hi all,

       

          Looking for a way to control a gateway listener from within an ESB action pipeline.

       

          The premise is that a fatal error condition is detected by some action in the pipeline and we now need to shutdown the listener to prevent future messages from being processed.

       

          Possible?

       

      Thanks,

      -Dennis

        • 1. Re: Programmatic way to control ESB listener from action pipeline?
          tcunning

          You sure can - the listeners have associated mbeans which you can start/stop.      Check out the jboss.esb category under the jmx-console and it should be apparent what your listener is.     

           

          I think this is documented in the Services guide.

          • 2. Re: Programmatic way to control ESB listener from action pipeline?
            dbuttery

            Thanks Tom!

             

            I was able to figure out how to use the MBeanServer and target my desired listener and then invoke the 'stop' action.

             

            Works like a charm!!

             

            Much appreciated,

            -Dennis

            • 3. Re: Programmatic way to control ESB listener from action pipeline?
              dbuttery

              Taking this to the next level ...

               

              Any thoughts on how this can be accomplished in a clustered environment?

               

              If I am running an instance of my ESB on each node in the cluster how would I shut them all down when errors are detected?

               

              Thanks again,

              -Dennis

              • 4. Re: Programmatic way to control ESB listener from action pipeline?
                tcunning

                There's a few options here, but there's really no silver bullet that I know of.

                 

                I think what you have to do is cycle through each node in the cluster, and execute the mbean operation on it.       There's a number of ways to do that :

                 

                - have all your nodes in the cluster register for JMX notifications, and then send them one and have a listener that shuts down the listener

                - set up a service that listens to a JMS topic that shuts down the listener - your actions can notify the topic when you detect the error

                - grab all the cluster addresses from JGroups and just run through them, shutting down the listener

                • 5. Re: Programmatic way to control ESB listener from action pipeline?
                  chmanosh

                  Hi Dennis/Tom,

                   

                      I am also in a similar situtation, Can you please post the code snippet or point me to the documentation on how to stop/start an ESB listener.

                   

                  Thanks

                  • 6. Re: Programmatic way to control ESB listener from action pipeline?
                    tcunning

                    Sure - if you go into the jmx-console (http://localhost:8080/jmx-console) and browse to the jboss.esb section, you should see MBeans for your listener (the listener-name will be specified in the MBean name) 

                     

                    Example :

                     

                    jboss.esb:deployment=jbpm.esb,listener-name=JMS-DCQListener,service-category=JBossESB-Internal,service-name=JBpmCallbackService

                     

                    That mbean contains a start and a stop method.     You need to get the MBean (https://community.jboss.org/message/508925#508925) and then call the start or stop method.

                    • 7. Re: Programmatic way to control ESB listener from action pipeline?
                      chmanosh

                      Thank you very much, it worked. Here is what I did, just in case if anyone else is look for a code snippet.

                       

                              MBeanServer mBeanServer = MBeanServerLocator.locateJBoss();

                                               ObjectName mBeanObjectName = new ObjectName("jboss.esb:deployment=jbpm.esb,listener-name=JMS-DCQListener,service-category=JBossESB-Internal,service-name=JBpmCallbackService");

                                               mBeanServer.invoke(mBeanObjectName, START, null, null);                     or

                       

                                               mBeanServer.invoke(mBeanObjectName, STOP, null, null);

                       

                      Above snippet only works after server is started and MBeans are already loaded. I wanted to have the Jboss ESB Lister/mbean deployed in stopped state. I could find a solution, the work around i had was stop the listener/mbean as soon server is started.

                       

                      Thanks

                      Manosh