4 Replies Latest reply on Jul 13, 2011 5:26 AM by Carlo de Wolf

    Messaging configuration in AS 7

    Andrew Murphy Newbie

      Hi All,


      I am migrating code to run in AS7 but I am struggling with my messaging configuration. The particular problem I face is my MDB's are not aware of the messages being sent, which I suspect has more to do with the references to JNDI in my MDB class annotations than my standalone.xml settings. I have spent hours googling, and tried everything possible to get the code to run, but now have to surrender and seek help!


      In order to assist in replicating the problem I face I have created a very basic test case which is attached, together with my standalone.xml file which is the standard Web Profile plus the messaging module settings from standalone-preview.xml.


      Please could someone run the code and tell me what I am doing wrong - your help will be greatly appreciated!


      Thank you,




      Development environment


      jboss-7.0.0.Final-SNAPSHOT ("Lightning"), Eclipse Indigo, Windows 7 (64-bit) and jdk1.6.0_24.

        • 1. Re: Messaging configuration in AS 7
          Jason Greene Master

          Hi Andrew,


          Unfortunately we won't have MDB support in Final. We deproritized anything non-web profile once we found out that due to recent certification requirements, we have to do extra work to make sure that there is no way that a user can consume the feature in whatever our certified configuration (and distribution) is. It will be one of the first features we have in early 7.1 releases, however if there is enough demand we may be able to backport something in a 7.0.x update.


          In the meantime you could use a traditional JMS listener inside of an ejb singleton deployment. Unless you would rather wait.

          • 2. Re: Messaging configuration in AS 7
            Andrew Murphy Newbie

            Hi Jason,


            Thank you for the prompt reply. I'll do as suggested to get my code running and will refactor once 7.1 is out.


            Regards, Andrew

            • 3. Re: Messaging configuration in AS 7
              Tom Jenkinson Master

              Is there an example of best practice for the route you suggested? Lets say I deployed a dummy EJB so that I could get an MDB:


              public interface MyFakeMDB extends javax.jms.MessageListener {





              public class MyFakeMDBImpl MyFakeMDB {


                   public void onMessage(Message message) {




              Assuming this is totally a fake EJB and I just want it to have MDB like behavior,  where should I put the JMS code to bind my message listener to the queue.


              I don't mean what code do I need to write:

              MessageConsumer mc = ((ConnectionFactory) new InitialContent().lookup("ConnectionFactory")).createConnection().createSession().createMessageConsumer((Destination)new InitialContext().lookup("foo"));



              What I mean is, where should this code go? I guess the constructor, but with AS7, will the EJB constructor only be called when someone accesses my the EJB through an interface, or is an instance of my EJB always created as soon as I deploy my ear/war?


              <quick grep of the internet/>


              Actually, I just checked online and can see that I can put this in the constructor,and put the following annotation as well:



              Which leads to the following:


              public interface MyFakeMDB extends javax.jms.MessageListener {






              public class MyFakeMDBImpl implements MyFakeMDB {


                   Context ic;


                   MessageConsumer mc;

                   public MyFakeMDBImpl() {

                        ConnectionFactory cf =  (ConnectionFactory) ic.lookup("ConnectionFactory");

                        Connection c = cf.createConnection();

                        Session s =  c.createSession();

                        Destination d =  (Destination)ic.lookup("foo");

                        mc = s.createMessageConsumer(d);




                   public void onMessage(Message message) {




              Does that look like the best way to do this? I suppose the only issue with this would be if I wanted JTA? In which case I would end up writing quite a bit more code to manage "XAConnectionFactory" code?

              • 4. Re: Messaging configuration in AS 7
                Carlo de Wolf Master

                I would say try out branch https://github.com/wolfc/jboss-as/tree/AS7-579. It contains the preliminary code for JMS MDB support.