5 Replies Latest reply on Dec 28, 2010 11:55 PM by clebert.suconic

    Spring consumer does not get invoked.

    groovenarula

      Hello,

       

      For some reason I just can't seem to get my Spring based SessionAwareMessageListener implimentation to consume messages from a 2.1.2.Final HornetQ based queue deployed on JBOSS AS 5.1.0.GA.

       

      I have defined the following queue in hornetq-jms.xml (in default-with-hornetq/deploy/hornetq.sar folder of JBOSS AS) :

       

      <queue name="PriceResponses">
              <entry name="/queue/PriceResponses"/>
      </queue>

       

      (I've left the reset of the configuration as is).

       

      The consumer is on a Spring based web application that implements 'SessionAwareMessageListener' called MessageReceiver :

       

      public class MessageReceiver implements SessionAwareMessageListener
      {   
          public void onMessage(Message message,Session jmssession) throws JMSException
          {
              System.out.println("Consumer invoked");
          }

      }

       

      The MessageReceiver is 'wired' in the 'applicationContext.xml' as follows:

       

          <bean id="PriceResponseQueue" class="org.hornetq.jms.client.HornetQQueue">
              <constructor-arg value="PriceResponses" />
          </bean>

       

          <bean id="messageListener" class="lzbws.jms.message.MessageReceiver" />
           
          <jms:listener-container container-type="default" connection-factory="jmsConnectionFactory" acknowledge="transacted">
                  <jms:listener destination="PriceResponseQueue" ref="messageListener" method="onMessage"/>
          </jms:listener-container>

       

      Using the jmx-console, I've verified that the queue does have 4 messages waiting to be delivered :

       

      JNDIBindingsR[Ljava.lang.String;Attribute exposed for management
      /queue/PriceResponses
         
      AddressRjava.lang.StringAttribute exposed for management
      jms.queue.PriceResponses    
      NameRjava.lang.StringAttribute exposed for management
      PriceResponses    
      TemporaryRbooleanAttribute exposed for management
      False    
      MessageCountRintAttribute exposed for management
      4    

       

      Yet when I start the tomcat application, I don't see any indication that the messages are getting consumed. In fact there's no error / exceptions in the logs either. If I chang the name of the queue (to see what would happen), I do get an exception that the queue was not found. But if the server name/queue details are valid, there are no errors or any addtional messages partaing to the invocation of the consumer in the queue.

       

      The same example works just fine with Jboss Messaging (after switching out the references to the HornetQ queue in the application context above). But it does not work with HornetQ.

       

      Any help will be appreciated as I would really pefer to deploy HornetQ instead of Jboss Messaging. But i'll be forced to stay with HornetQ if I can't get this to work.

       

      Thanks in advance,

      Gurvinder

        • 1. Re: Spring consumer does not get invoked.
          clebert.suconic

          You need to get this to a level we can understand :-) Maybe an easy way to replicate would help me or other people to identify what's going on.

          • 2. Re: Spring consumer does not get invoked.
            groovenarula

            I'll try to upload a zip file of the various components upload later in the day ! Would that help ?

            • 3. Re: Spring consumer does not get invoked.
              clebert.suconic

              I just need something simple. You need to isolate your issue to the basic bear bones of your question. So, you need to upload something simple.

               

              Keep in mind I won't be able to evaluate a very complex piece of software. that would be more consulting.. and doing it for free here would be free consulting.

               

               

              Keep in mind also that I don't know spring. So, you need to get something anyone could understand. It could be anyone from the community.

              • 4. Re: Spring consumer does not get invoked.
                groovenarula

                It looks like I managed to get it to work.  I replaced this section of the applicationContext section :

                 

                <jms:listener-container container-type="default" connection-factory="jmsConnectionFactory" acknowledge="transacted">
                            <jms:listener destination="PriceResponseQueue" ref="messageListener" method="onMessage"/>

                </jms:listener-container>

                 

                with this

                      <bean id="listenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
                            <property name="concurrentConsumers" value="5" />
                            <property name="connectionFactory" ref="jmsConnectionFactory" />
                            <property name="destination" ref="PriceResponseQueue" />
                            <property name="messageListener" ref="messageListener" />
                      </bean>

                 

                and it started working !

                 

                Thanks for all your help. Your request for a simplified example forced me to experiment with other options :-) . And helped me get to a solution.

                • 5. Re: Spring consumer does not get invoked.
                  clebert.suconic
                  Your request for a simplified example forced me to experiment with other options :-) . And helped me get to a solution.

                   

                   

                  This is actually what I was hoping for :-)

                   

                  Thanks! :-)