1 Reply Latest reply on Jul 20, 2010 10:27 AM by Clebert Suconic

    Best practice to avoid MDB

    reza g Newbie



      I need to write a simple message consumer (that receives a soap message and forwards it to a web service) and run it when HornetQ standalone starts up. I will have a cluster of standalone HornetQ servers, each having this simple forwarder.


      What is the best way of achiveing this when I want to have a permanent listener while avoiding MDBs?



        • 1. Re: Best practice to avoid MDB
          Clebert Suconic Master

          A good idea would be you writing a MC Bean



          public class MyBean


              public void start()


                     // instantiate factories (JNDI or direct instantiation),

                    // instantiate a session... etc

                    // setup a consumer  (Message listener)



              public void stop()


                         // close the connections, sessions.. etc







          Add it to the server's classpath



          And change hornetq-beans.xml to add your bean:


          <bean name="MyClient" class="my.package.MyClass/>




          You would be on the same VM as the Standalone server. You could even use InVM.



          You will probably need a dependency to the HornetQServer, so your bean doesn start before the HornetQServer.

          1 of 1 people found this helpful