New Consumer instance is created when a message is sent on other queue

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

New Consumer instance is created when a message is sent on other queue

This post was updated on .
Hi all,

I am facing an issue while developing a basic application of server client. Each client will have a dedicated client queue to consume message from the server and a single queue for a server to consume messages from the clients.

I am using apache-activemq-5.8.0 with spring framework.
This is my configuration file :
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""

    <context:component-scan base-package="com.test.common.orderapp" />

    <bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL">
        <property name=""></property>
    <bean id="worker1" class="org.apache.activemq.command.ActiveMQQueue">
        <constructor-arg value="worker1Queue"/>
    <bean id="worker2" class="org.apache.activemq.command.ActiveMQQueue">
        <constructor-arg value="worker2Queue"/>
    <bean id="response" class="org.apache.activemq.command.ActiveMQQueue" >
        <constructor-arg value="responseQueue"/>
    <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="connectionFactory" />
        <property name="defaultDestination" ref="worker1" />
        <bean id="orderSender" class="com.test.common.orderapp.producer.OrderSender"> </bean>
    <bean id="orderService" class="com.test.common.orderapp.producer.OrderService">
    <property name = "orderSender" ref = "orderSender" />
        <bean id="orderListener" class="com.test.common.orderapp.listener.OrderListener"> </bean>

              acknowledge="auto" >
            <jms:listener destination="responseQueue" ref="orderListener" method="orderReceived" />

My question is:

There are basically two client with worker1 and worker2 queue.
Now whenever I load configuration file using
ApplicationContext ctx = new ClassPathXmlApplicationContext("app-context.xml");
            OrderService orderService = (OrderService) ctx.getBean("orderService");

"and send the message to any queue of worker a consumer is created on response queue."

worker Queue: Consumer 1 Enqueue 10 Dequeue 10
Response Queue: Consumer 11 Enqueue 1 Dequeue 1

Some time messages also remain in pending state .

What can be the reason? Is my approach wrong ??

Thanks ,
Mohit Jain