8 Replies Latest reply on Jul 29, 2015 3:13 PM by Justin Bertram

    MDB not getting invoked with messages sent to queue

    Manish Sharma Newbie

      Hi,

      Relates to JBOSS 6.4.

      Looks I have incorrect set-ups due to which the MDB isn't invoked even with messages on queue

       

      Below is the domain.xml file

      <jms-destinations>

                              <jms-queue name="XYZ_ResponseQueue">

                                  <entry name="java:jboss/exported/XYZ_ResponseQueue"/>

                                  <entry name="XYZ_ResponseQueue"/>

                                  <durable>true</durable>

                              </jms-queue>

      </jms-destinations>

      Content in ejb-jar.xml

      <?xml version="1.0" encoding="UTF-8"?>

      <ejb-jar version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"

      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee

      http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">

        <display-name>TES App</display-name>

        <enterprise-beans>

          <message-driven>

              <display-name>TES</display-name>

              <ejb-name>TES_MDB</ejb-name>

              <ejb-class>com.bgcp3.tes.tesprocess.TFInterfaceMessageListener</ejb-class>

            <transaction-type>Container</transaction-type>

              <activation-config>

              <activation-config-property>

                <activation-config-property-name>destinationType</activation-config-property-name>

                <activation-config-property-value>javax.jms.Queue</activation-config-property-value>

              </activation-config-property>

              <activation-config-property>

                <activation-config-property-name>destination</activation-config-property-name>

                <activation-config-property-value>java:jboss/exported/XYZ_ResponseQueue</activation-config-property-value>

              </activation-config-property>

            </activation-config>

          </message-driven>

        </enterprise-beans>

        <assembly-descriptor>

          <container-transaction>

              <method>

                <ejb-name>TES_MDB</ejb-name> 

                <method-name>*</method-name>

              </method>

                <trans-attribute>Required</trans-attribute>

            </container-transaction>

        </assembly-descriptor>

      </ejb-jar>

      content in JBOSS.xml

      <?xml version="1.0" encoding="UTF-8"?>

          <!DOCTYPE jboss PUBLIC

                "-//JBoss//DTD JBOSS 4.0//EN"

                "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">

          <jboss>

          <enterprise-beans>

          <message-driven>

          <ejb-name>TES_MDB</ejb-name>

          <destination-jndi-name>XYZ_ResponseQueue</destination-jndi-name>

          <resource-ref>

          <res-ref-name>XYZ_ResponseQueue</res-ref-name>

          <jndi-name>java:jboss/exported/XYZ_ResponseQueue</jndi-name>

          </resource-ref>

          </message-driven>

          </enterprise-beans>

          </jboss>

       

      Although the messages are present in the XYZ_ResponseQueue but the MDB doesn't gets activated.

      Would it be possible to comment on what is wrong in above set-up.


      In above scenario - a client is sending messages to the above queue supposed to be read by MDB.


      Many thanks in advance.

        • 1. Re: MDB not getting invoked with messages sent to queue
          Terrence Curran Newbie

          I don't think you need the jboss.xml file.  Did you try changing the destination in ejb-jar.xml to just XYZ_ResponseQueue rather than pointing at the exported queue?

          • 2. Re: MDB not getting invoked with messages sent to queue
            Manish Sharma Newbie

            Hi Terrence,

             

            I have tried without the exported queue (and without the jboss.xml file) and still the MDB is not getting invoked.

            Any other clue?

            • 3. Re: MDB not getting invoked with messages sent to queue
              Terrence Curran Newbie

              It's tough to tell without seeing your entire standalone.xml and the code in your war file.

               

              a few things I would look at:

              - try adding <message-destination-type>javax.jms.Queue</message-destination-type> to your ejb-jar.xml under <message-driven>

              - make sure ee and ejb3 modules are loaded in your standalone.xml

              - make sure ejb-jar.xml is in the correct place. for .war files it should be right in WEB-INF/

              • 4. Re: MDB not getting invoked with messages sent to queue
                Manish Sharma Newbie

                Hi Terrence,

                I found the remote client which generated messsages for XYZ_ResponseQueue - all the messages are getting redirected to DLQ?

                So  now I am focussing onto client program.

                The java code written is as follows

                 

                Properties properties = new Properties(); 

                  //properties.setProperty(JMSClassHost, JMSHost);

                  //properties.setProperty(JMSClassPort, JMSPort);

                  properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

                  properties.put(Context.PROVIDER_URL, "remote://localhost:4449");

                  properties.put(Context.SECURITY_PRINCIPAL, "guest");

                  properties.put(Context.SECURITY_CREDENTIALS, "guestpassword");

                  try{

                 

                  ctx = new InitialContext(properties);

                  queueConnectionFactory = (QueueConnectionFactory) ctx.lookup("XYZ_Connection_Factory");

                  responseQueue = (Queue) ctx.lookup("XYZ_ResponseQueue");

                 

                  connection = queueConnectionFactory.createQueueConnection();

                  session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

                  sender   = session.createSender(responseQueue);

                  connection.start();

                 

                  TextMessage textMessage = session.createTextMessage("ABCDEF " + Calendar.getInstance().getTime());

                  sender.send(textMessage);

                  System.out.println("Sending Queue Name: "+sender.getQueue().getQueueName());

                  System.out.println("Sending message ID: "+textMessage.getJMSMessageID());

                  sender.close();

                  session.close();

                  connection.close();

                 

                In domain.xml file - below is the set-up

                <connection-factory name="XYZ_Connection_Factory">

                                            <connectors>

                                                <connector-ref connector-name="netty"/>

                                            </connectors>

                                            <entries>

                                                <entry name="java:jboss/exported/XYZ_Connection_Factory"/>

                                                <entry name="XYZ_Connection_Factory"/>

                                            </entries>

                                            <compress-large-messages>false</compress-large-messages>

                                            <failover-on-initial-connection>false</failover-on-initial-connection>

                                            <use-global-pools>true</use-global-pools>

                </connection-factory>

                <jms-destinations>

                                        <jms-queue name="ExpiryQueue">

                                            <entry name="java:/jms/queue/ExpiryQueue"/>

                                        </jms-queue>

                                        <jms-queue name="DLQ">

                                            <entry name="java:/jms/queue/DLQ"/>                            

                                        </jms-queue>

                                        <jms-queue name="XYZ_ResponseQueue">

                                            <entry name="java:jboss/exported/XYZ_ResponseQueue"/>

                                            <entry name="XYZ_ResponseQueue"/>

                                            <durable>true</durable>

                                        </jms-queue>

                <jms-destinations>


                For some reason the message is going to the DLQ queue.



                • 5. Re: MDB not getting invoked with messages sent to queue
                  Terrence Curran Newbie

                  This code you posted is for the sender. If it is going to DLQ then there is no problem with the sender, the message is being sent properly.

                   

                  Things end up in the DLQ when the receiver client session throws an exception. I would debug there and try to figure out what is going on.

                  • 6. Re: MDB not getting invoked with messages sent to queue
                    Justin Bertram Master

                    Typically messages would wind up in the DLQ because of delivery failures which indicates to me that the problem might be that the MDB actually is receiving the messages but is failing for some reason causing the message delivery to fail and eventually causing the messages to be sent to the DLQ.

                    • 7. Re: MDB not getting invoked with messages sent to queue
                      Manish Sharma Newbie

                      When I enable the deployed EAR, in the Runtime > Queue Metrics the corresponding "Consumer Count" increases to 15. This is surprising as I have deployed only 1 MDB. Is their any configuration that would lead it to shoot to 15 number? If I bring down the Application, the consumer count becomes 0.

                      I will organize and post the code. here

                      • 8. Re: MDB not getting invoked with messages sent to queue
                        Justin Bertram Master

                        This is the expected behavior.  An MDB uses a pool of sessions for consuming messages so that messages can be consumed concurrently for increased performance.  This is one of the benefits of using MDBs.  The default session pool size is 15 and can be controlled via the "maxSession" activation configuration property.