Announcement Announcement Module
Collapse
No announcement yet.
Message Listener Issue - Tomcat6, Spring 2.5.3 and JMS 1.1 & ActiveMQ 5.1 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Message Listener Issue - Tomcat6, Spring 2.5.3 and JMS 1.1 & ActiveMQ 5.1

    Hi all,

    I am trying to test some simple JMS application.

    I am using Tomcat6, Spring 2.5.3 and JMS 1.1 & ActiveMQ 5.1

    I created a topic called status_topic by starting ActiveMQ at the URL:
    http://localhost:8161/admin/

    Here is my JMS Configuration:

    Code:
    <?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.xsd">
    
        <bean id="status_topic" class="org.apache.activemq.command.ActiveMQTopic">
            <constructor-arg value="status_topic"/>
        </bean>
     
        <bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
            <property name="brokerURL" value="tcp://localhost:61616"/>
        </bean>
    	<bean id="messageListener" class="com.ss.ejbs.mdb.mdp.SSMessageListener"/>	
    	
    	<!-- And this is the message listener container -->
    	<!--  -->
    	<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    		<property name="connectionFactory" ref="connectionFactory"/>
    		<property name="destination" ref="status_topic"/>
    		<property name="messageListener" ref="messageListener"/>
    		<property name="sessionTransacted" value="true"/>		
    	</bean>
    	
    	<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
            <property name="connectionFactory" ref="connectionFactory"/>
            <property name="defaultDestination" ref="status_topic"/>
        </bean> 
    
    </beans>
    Listener Class:
    Code:
    public class SSMessageListener implements MessageListener {
    
    	/** Logger for this class and subclasses */
    	protected final Log log = LogFactory.getLog(getClass());
    	
    	public void onMessage(Message message) {
    		
    		if (message instanceof TextMessage) {
    			try {
    //				log.info("Message: " + ((TextMessage)message).getText());
    				System.out.println(((TextMessage) message).getText());
    			} catch (JMSException ex) {
    				throw new RuntimeException(ex);
    			}
    		} else {
    			throw new IllegalArgumentException("Message must be of type TextMessage");
    		}
    	}
    
    }
    I deployed this code on tomcat and I sent a message to the topic using the URL http://localhost:8161/admin/

    I noticed nothing happened and SSMessageListener class onMessage(message) was never invoked. Please tell me what else I need to do.

    Your fast response is greatly appreciated.

    Thanks in advance.
    rsrch

  • #2
    Sorry Folks. This seems to be working.

    Comment

    Working...
    X