3 Replies Latest reply on Sep 20, 2011 5:36 AM by Phoncy Joseph

    JMS onMessage() isn't executing always

    Tanusree Dev Newbie

      I'm using Jboss 5.1.0 AS in my project.I've configured queue properly in destinations-service.xml . I've written the code to get JMS connectivity and in my MDB onMessage() is also written properly, but the onMessage() isn't executing always , sometimes it may call or sometimes may not. As a result message isn't delivering properly.

      Plz try to give any suggestion.

      Thanks in advance.

        • 1. Re: JMS onMessage() isn't executing always
          Peter Johnson Master

          What do you mean by "message isn't delivering properly"? Is the message ill-formed, or is it not being delivered at all?

           

          If you have everything "configured properly" and "written properly" then it should also be working properly. How about if you share your MDB source and the queue configuration. Also, tell use which database you are using for JMS, and which configuration you are running.

           

          Finally, I recommend that you not modify the existing destinations-service.xml file; instead create your own *-service.xml file with your queue's configuration.

          • 2. Re: JMS onMessage() isn't executing always
            Tanusree Dev Newbie

            I'm using SQLServer2005 database and default destination-service.xml.

             

            destination-service.xml:-------------------------->

             

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

             

            <!--

                 Messaging Destinations deployment descriptor.

             

                 $Id: destinations-service.xml 81065 2008-11-14 15:09:16Z dimitris@jboss.org $

            -->

             

            <server>

             

               <!--

                  The Default Dead Letter Queue. This destination is a dependency of an EJB MDB container.

               -->

             

               <mbean code="org.jboss.jms.server.destination.QueueService"

                  name="jboss.messaging.destination:service=Queue,name=DLQ"

                  xmbean-dd="xmdesc/Queue-xmbean.xml">

                  <annotation>@org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.QueueServiceMO)</annotation>     

                  <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

                  <depends>jboss.messaging:service=PostOffice</depends>

               </mbean>

              

               <!--

                  The Default Expiry Queue.

               -->

             

               <mbean code="org.jboss.jms.server.destination.QueueService"

                  name="jboss.messaging.destination:service=Queue,name=ExpiryQueue"

                  xmbean-dd="xmdesc/Queue-xmbean.xml">

                  <annotation>@org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.QueueServiceMO)</annotation>     

                  <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

                  <depends>jboss.messaging:service=PostOffice</depends>

               </mbean>  

             

               <!--

                    Example destinations.

               -->

             

               <mbean code="org.jboss.jms.server.destination.TopicService"

                  name="jboss.messaging.destination:service=Topic,name=testTopic"

                  xmbean-dd="xmdesc/Topic-xmbean.xml">

                  <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

                  <depends>jboss.messaging:service=PostOffice</depends>

                  <attribute name="SecurityConfig">

                     <security>

                        <role name="guest" read="true" write="true"/>

                        <role name="publisher" read="true" write="true" create="false"/>

                        <role name="durpublisher" read="true" write="true" create="true"/>

                     </security>

                  </attribute>

               </mbean>

             

               <mbean code="org.jboss.jms.server.destination.TopicService"

                  name="jboss.messaging.destination:service=Topic,name=securedTopic"

                  xmbean-dd="xmdesc/Topic-xmbean.xml">

                  <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

                  <depends>jboss.messaging:service=PostOffice</depends>

                  <attribute name="SecurityConfig">

                     <security>

                        <role name="publisher" read="true" write="true" create="false"/>

                     </security>

                  </attribute>

               </mbean>

             

               <mbean code="org.jboss.jms.server.destination.TopicService"

                  name="jboss.messaging.destination:service=Topic,name=testDurableTopic"

                  xmbean-dd="xmdesc/Topic-xmbean.xml">

                  <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

                  <depends>jboss.messaging:service=PostOffice</depends>

                  <attribute name="SecurityConfig">

                     <security>

                        <role name="guest" read="true" write="true"/>

                        <role name="publisher" read="true" write="true" create="false"/>

                        <role name="durpublisher" read="true" write="true" create="true"/>

                     </security>

                  </attribute>

               </mbean>

             

               <mbean code="org.jboss.jms.server.destination.QueueService"

                  name="jboss.messaging.destination:service=Queue,name=testQueue"

                  xmbean-dd="xmdesc/Queue-xmbean.xml">

                  <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

                  <depends>jboss.messaging:service=PostOffice</depends>

                  <attribute name="SecurityConfig">

                     <security>

                        <role name="guest" read="true" write="true"/>

                        <role name="publisher" read="true" write="true" create="false"/>

                        <role name="noacc" read="false" write="false" create="false"/>

                     </security>

                  </attribute>

               </mbean>

             

               <mbean code="org.jboss.jms.server.destination.QueueService"

                  name="jboss.messaging.destination:service=Queue,name=A"

                  xmbean-dd="xmdesc/Queue-xmbean.xml">

                  <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

                  <depends>jboss.messaging:service=PostOffice</depends>     

               </mbean>

             

               <mbean code="org.jboss.jms.server.destination.QueueService"

                  name="jboss.messaging.destination:service=Queue,name=B"

                  xmbean-dd="xmdesc/Queue-xmbean.xml">

                  <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

                  <depends>jboss.messaging:service=PostOffice</depends>

               </mbean>

             

               <mbean code="org.jboss.jms.server.destination.QueueService"

                  name="jboss.messaging.destination:service=Queue,name=C"

                  xmbean-dd="xmdesc/Queue-xmbean.xml">

                  <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

                  <depends>jboss.messaging:service=PostOffice</depends>

               </mbean>

             

               <mbean code="org.jboss.jms.server.destination.QueueService"

                  name="jboss.messaging.destination:service=Queue,name=D"

                  xmbean-dd="xmdesc/Queue-xmbean.xml">

                  <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

                  <depends>jboss.messaging:service=PostOffice</depends>

               </mbean>

             

               <mbean code="org.jboss.jms.server.destination.QueueService"

                  name="jboss.messaging.destination:service=Queue,name=ex"

                  xmbean-dd="xmdesc/Queue-xmbean.xml">

                  <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

                  <depends>jboss.messaging:service=PostOffice</depends>

               </mbean>

              

               <!-- It's possible for indiviual queues and topics to use a specific queue for

               an expiry or DLQ -->

              

               <mbean code="org.jboss.jms.server.destination.QueueService"

                  name="jboss.messaging.destination:service=Queue,name=PrivateDLQ"

                  xmbean-dd="xmdesc/Queue-xmbean.xml">

                  <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

                  <depends>jboss.messaging:service=PostOffice</depends>

               </mbean>

              

               <mbean code="org.jboss.jms.server.destination.QueueService"

                  name="jboss.messaging.destination:service=Queue,name=PrivateExpiryQueue"

                  xmbean-dd="xmdesc/Queue-xmbean.xml">

                  <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

                  <depends>jboss.messaging:service=PostOffice</depends>

               </mbean>     

              

               <mbean code="org.jboss.jms.server.destination.QueueService"

                  name="jboss.messaging.destination:service=Queue,name=QueueWithOwnDLQAndExpiryQueue"

                  xmbean-dd="xmdesc/Queue-xmbean.xml">

                  <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

                  <depends>jboss.messaging:service=PostOffice</depends>

                  <attribute name="DLQ">jboss.messaging.destination:service=Queue,name=PrivateDLQ</attribute>

                  <attribute name="ExpiryQueue">jboss.messaging.destination:service=Queue,name=PrivateExpiryQueue</attribute>

               </mbean>

              

               <mbean code="org.jboss.jms.server.destination.TopicService"

                  name="jboss.messaging.destination:service=Topic,name=TopicWithOwnDLQAndExpiryQueue"

                  xmbean-dd="xmdesc/Topic-xmbean.xml">

                  <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

                  <depends>jboss.messaging:service=PostOffice</depends>

                  <attribute name="DLQ">jboss.messaging.destination:service=Queue,name=PrivateDLQ</attribute>

                  <attribute name="ExpiryQueue">jboss.messaging.destination:service=Queue,name=PrivateExpiryQueue</attribute>

               </mbean>      

              

               <!-- Queues and Topics can also specify their own redelivery delay -->

              

               <mbean code="org.jboss.jms.server.destination.QueueService"

                  name="jboss.messaging.destination:service=Queue,name=QueueWithOwnRedeliveryDelay"

                  xmbean-dd="xmdesc/Queue-xmbean.xml">

                  <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

                  <depends>jboss.messaging:service=PostOffice</depends>

                  <attribute name="RedeliveryDelay">5000</attribute>

               </mbean>

              

               <mbean code="org.jboss.jms.server.destination.TopicService"

                  name="jboss.messaging.destination:service=Topic,name=TopicWithOwnRedeliveryDelay"

                  xmbean-dd="xmdesc/Topic-xmbean.xml">

                  <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

                  <depends>jboss.messaging:service=PostOffice</depends>

                  <attribute name="RedeliveryDelay">5000</attribute>

               </mbean>    

              

               <!--

                    Example clustered destinations.

               -->

              

               <mbean code="org.jboss.jms.server.destination.QueueService"

                  name="jboss.messaging.destination:service=Queue,name=testDistributedQueue"

                  xmbean-dd="xmdesc/Queue-xmbean.xml">

                  <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

                  <depends>jboss.messaging:service=PostOffice</depends>

                  <attribute name="Clustered">true</attribute>

               </mbean>  

              

               <mbean code="org.jboss.jms.server.destination.TopicService"

                  name="jboss.messaging.destination:service=Topic,name=testDistributedTopic"

                  xmbean-dd="xmdesc/Topic-xmbean.xml">

                  <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>

                  <depends>jboss.messaging:service=PostOffice</depends>

                  <attribute name="Clustered">true</attribute>

               </mbean>  

             

            </server>

             

             

            Queue configuration code is :------------------------------------------------------->

             

                           Context messaging = TransactionManager.getInitialContext();

                            QueueConnectionFactory queueConnectionFactory

                                    = (QueueConnectionFactory) messaging.lookup("java:/XAConnectionFactory");

                           

                            QueueConnection con=queueConnectionFactory.createQueueConnection();               

                            QueueSession session= con.createQueueSession(true,Session.DUPS_OK_ACKNOWLEDGE);

                            Vector vec=new Vector();

                            vec.add(instanceDto);

                            vec.add(propertyDto);

                            vec.add(priority);

                            vec.add(observedValue);

                            Queue queue= (Queue)messaging.lookup("queue/A");              

                            ObjectMessage msg=session.createObjectMessage();

                            msg.setObject(vec);             

                            QueueSender sender=session.createSender(queue);

                            con.start();               

                            sender.send(msg);               

                            session.close();

                            con.close();

             

            Thanks for reply

            • 3. Re: JMS onMessage() isn't executing always
              Phoncy Joseph Newbie

              Hi Tanusree,

               

                I'm also facing similar issue with Jboss 5.1.0 AS in my project. The message appears in the queue immediately after it has been sent. But the  onMessage() method is not getting invoked. The method is getting called after a delay of few hours. Please let me know if you have got a solution.

               

              Thanks