Announcement Announcement Module
Collapse
No announcement yet.
Issue with MessageListenerAdapter class Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Issue with MessageListenerAdapter class

    Hi,
    I have configured applicationContext.xml and corresponding beans like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

    <!-- Where to listen -->
    <bean id="testConnectionFactory" class="com.tibco.tibjms.TibjmsXAQueueConnectionFac tory" lazy-init="false">
    </bean>

    <!-- The name of the queue -->
    <bean id="testMessageQueue" class="com.tibco.tibjms.TibjmsQueue" lazy-init="false">
    <constructor-arg value="SERVICES.SPRING_TEST" />
    </bean>

    <!-- The container default has transaction capability -->
    <bean id="testListenerContainer" class="org.springframework.jms.listener.DefaultMes sageListenerContainer" lazy-init="false">
    <property name="connectionFactory" ref="testConnectionFactory"/>
    <property name="destination" ref="testMessageQueue"/>
    <property name="messageListener" ref="testListener"/>
    <property name="concurrentConsumers" value="3"/>
    </bean>

    <!-- The listenerAdapter forwards to our POJO to insert the event -->
    <bean id="testListener" class="org.springframework.jms.listener.adapter.Me ssageListenerAdapter" lazy-init="false">
    <constructor-arg>
    <bean class="com.java.test.DefaultTextMessageDelegateTes t"/>
    </constructor-arg>
    <property name="defaultListenerMethod" value="receive"/>
    <property name="messageConverter">
    <null/>
    </property>

    </bean>
    </beans>

    And my MDP is like this ...

    public class DefaultTextMessageDelegateTest {

    public DefaultTextMessageDelegateTest() throws Exception {

    System.out.println(" ==== TEST ====");


    }


    public String receive(TextMessage message) {

    try {

    String messageStr = message.getText();

    System.out.println("Message coming is =======\n\n: " + messageStr);

    Queue queue = (Queue) message.getJMSReplyTo();

    Enumeration names = message.getPropertyNames();

    while (names.hasMoreElements()) {
    String name = (String) names.nextElement();
    String value = message.getStringProperty(name);

    System.out.println("Name: " + name + " Value: " + value);
    }


    if (queue == null) {
    System.out.println("Queue is null");
    } else {
    System.out.println("Queue Name is: " + queue.getQueueName());
    }


    return "It is working good";

    } catch (Exception e) {

    e.printStackTrace();

    }

    return "An error occured";


    }
    }

    The issue is that I am not getting any TextMessage back on the queue that is specified as JMSReplyTo in the original message. Everything else is working fine. I am seeing all the debug messages and the original TextMessage in the weblogic console.

    I am using weblogic 8.1 service pack 4 and JAVA 1.4.2 and TIBCO JMS.

    Your help is greatly appreciated.

    Thanks in advance.

  • #2
    Can one of you please take a look into this one? Thank you very much.

    Comment


    • #3
      First of all when posting code please use the [ code][/code ] tags the make your post reable.

      I suggest you crank up the loglevel to debug and see what is happing.

      Comment


      • #4
        The reason I am expecting a TextMessage on another queue that is specified in "JMSReplyTo" is because the spring/JMS specification says that any non-null value is converted to a TextMessage and sent to the destination defined in the JMS Reply-To property of the original message. Please take a look into this one.

        Comment


        • #5
          As I stated before crank up the loglevel to debug and see what is happening! Also instead of using 3 concurrent consumers start with 1 (we had some issues with multiple consumers).

          Comment


          • #6
            Thanks for the prompt reply. I see the following error in the logs:

            Code:
            [2007-09-05 15:02:08,161] [WARN] [org.springframework.jms.listener.DefaultMessageListenerContainer] [Execution of JMS message listener failed]
            org.springframework.jms.support.converter.MessageConversionException: No MessageConverter specified - cannot handle message [RAJA ... it is working good]
            	at org.springframework.jms.listener.adapter.MessageListenerAdapter.buildMessage(MessageListenerAdapter.java:510)
            	at org.springframework.jms.listener.adapter.MessageListenerAdapter.handleResult(MessageListenerAdapter.java:482)
            	at org.springframework.jms.listener.adapter.MessageListenerAdapter.onMessage(MessageListenerAdapter.java:355)
            	at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:485)
            	at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:442)
            	at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:414)
            	at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:309)
            	at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:254)
            	at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:871)
            	at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:811)
            	at java.lang.Thread.run(Thread.java:534)

            Comment


            • #7
              If you check the source code you will see that it fails to locate a MessageConverter. For some reason you found it necessary in your configuration to set the MessageConverter to null. Which quite effectivly disables returning any responses.

              Code:
              <bean id="testListener" class="org.springframework.jms.listener.adapter.MessageListenerAdapter">
              	<constructor-arg>
              		<bean class="com.java.test.DefaultTextMessageDelegateTest"/>
              	</constructor-arg>
              	<property name="defaultListenerMethod" value="receive"/>
              	<property name="messageConverter">
              		<null/>
              	</property>
              </bean>
              Remove the marked lines and it should work.

              Comment


              • #8
                I created new message converter and everything seems to be working fine. Thanks a lot for all your help.

                Comment


                • #9
                  You don't need a MessageConverter just remove the lines and the default message converter will do it's job. It is the SimpleMessageConverter.

                  Comment


                  • #10
                    Yes, that is also working. Thanks.

                    Comment


                    • #11
                      Originally posted by Marten Deinum View Post
                      You don't need a MessageConverter just remove the lines and the default message converter will do it's job.
                      My understanding from the spring documentation is that you should set the message converter to null if you want to receive the TextMessage object.

                      public interface ResponsiveTextMessageDelegate {
                      // notice the return type...
                      String receive(TextMessage message);
                      }

                      The above example is from the doucmentation and returns a String. However with no converter specified the response fails. (You do receive a TextMessage)

                      Is the documentation wrong?

                      Comment

                      Working...
                      X