Announcement Announcement Module
No announcement yet.
JMS Async receive problem. Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • JMS Async receive problem.

    Hello. I want to write simple application which would receive some JMS messages from Queue. I'm using Spring and Sonic MQ. It works great when i use sync receive() method from my JMSTemplate object, but nothing work async.
    This is my Spring xml.

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

    <bean id = "jmsConnectionFactory" class = "org.apache.activemq.spring.ActiveMQConnectionFact ory">
    <property name ="brokerURL" value="tcp://localhost:61617"/>
    <bean id="connectionFactory" class="org.springframework.jms.connection.CachingC onnectionFactory">
    <constructor-arg ref="jmsConnectionFactory" />
    <property name="exceptionListener" ref="ExceptionListener" />
    <property name="sessionCacheSize" value="100" />

    <!-- Connection factories -->
    <bean id = "sonicConnectionFactory" class = "progress.message.jclient.QueueConnectionFacto ry">
    <property name = "BrokerURL" value = "sonic:2506"/>
    <property name = "DefaultUser" value = "Administrator"/>
    <property name = "DefaultPassword" value = "password"/>
    <property name = "ReconnectInterval" value = "30"/>
    <property name = "ReconnectTimeout" value = "0"/>

    <!-- Connection factory cached decorators -->
    <bean id = "cachedSonicFactoryDecorator" class = "org.springframework.jms.connection.CachingConnect ionFactory" >
    <constructor-arg ref = "sonicConnectionFactory"/>
    <property name="SessionCacheSize" value="1"/>

    <!-- Transaction managers -->
    <bean id = "transactionManager" class = "org.springframework.jms.connection.JmsTransaction Manager">
    <property name = "ConnectionFactory" ref = "cachedActiveMQFactoryDecorator"/>

    <!-- Destinations -->
    <bean id = "sonicQueue" class= "progress.message.jclient.Queue">
    <property name="QueueName" value="test.m1"/>

    <!-- JMSTempates -->
    <bean id = "JMSReceiverTemplate" class = "org.springframework.jms.core.JmsTemplate">
    <constructor-arg ref = "cachedSonicFactoryDecorator"/>
    <property name = "DefaultDestination" ref = "sonicQueue"/>
    <property name = "SessionTransacted" value = "true"/>
    <property name = "SessionAcknowledgeModeName" value = "SESSION_TRANSACTED"/>

    <!-- My POJOs -->

    <bean id = "MessageRecieveService" class="com.tander.receiver.MessageReceiver" init-method="loadPropertiesAndStart" destroy-method="stop" >
    <property name = "jmsTemplate" ref = "JMSReceiverTemplate"/>
    <property name = "transactionManager" ref = "transactionManager"/>
    <property name = "messageProcessor" ref = "ActiveMQMessageProcessor"/>

    <bean id="myJmsContainer" class="org.springframework.jms.listener.DefaultMes sageListenerContainer">
    <property name="connectionFactory" ref="cachedSonicFactoryDecorator"/>
    <property name="destinationName" value="sonicQueue"/>
    <property name="sessionTransacted" value="true"/>
    <property name="messageListener" ref="MessageRecieveService" />
    <property name="concurrentConsumers" value="1" />
    <property name="receiveTimeout" value="30000" />


    My listener:

    public void onMessage(javax.jms.Message arg0) {
    System.out.println("IM A RAINBOW !!!");

    my main class:

    Resource res = new FileSystemResource("bin/META-INF/spring/MessageReciever.xml");
    XmlBeanFactory factory = new XmlBeanFactory(res);

    Queue is full of msgs but listener doesn't hear anything

    Im try to call onMessage from Session callback, but this:

    public Object doInJms(Session arg0) throws JMSException {
    System.out.println(arg0.getMessageListener()); // NULL
    System.out.println(arg0.getMessageListener()); //MYCLASS
    arg0.getMessageListener().onMessage(null); // Works
    return null;

    Im read a lot of posts but cant find any solution or even any direction to find it. May be here someone can give me advice ?

    Sry me for my bad english and my propably stupid question.

  • #2
    JMS Async receive

    i cant find your code for sending message on queue,which further will be consumed by messageListner using onMessage().
    your deployed container and listner looks good but you need to write code for sending side.
    for a typical Async scenario you can use