1

We have a requirement where in I'll be deploying an application on n number of servers, say S1, S2 ,....Sn.There is an activeMQ queue defined on one of the servers , say S1.I have configured my servers to produce messages and place them in the same queue which is configured in S1. While all the servers are configured to use the same queue for storing the produced messages, my requirement is to have only one of the n servers process all the messages from the queue , again let's say S1.So while all the servers ranging from S1,S2,...Sn can produce and store them on the queue configured on S1,only S1 should process all of them.Hence I have disabled the "MessageListener" part of all the servers except S1. For some reason though, S1 doesn't process everything. I sense that the queue is distributing the messages in a round robin fashion in spite of the other Listeners being disabled. S1 processes every alternate message in a case where two servers are accessing a queue. Any help to resolve this issue would be greatly appreciated.

Note: If it might help,I'm using Spring JMS template and complete Spring XML based configuration for JMS.

Here is my XML configuration snippet

<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://ipaddress:61617"/>
</bean>
<bean id="cscoDest" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="STOCKS.CSCO" />
</bean>
<!--The message listener-->
<bean id="portfolioListener" class="my.test.jms.Listener">
</bean>
<!--Spring DMLC-->
<bean id="cscoConsumer" class="org.springframework.jms.listener.DefaultMessageListenerContainer102">
<property name="connectionFactory" ref="jmsConnectionFactory" />
<property name="destination" ref="cscoDest" />
<property name="messageListener" ref="portfolioListener" />
</bean>
<!--Spring JMS Template-->
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>
<bean id="stockPublisher" class="my.test.jms.SpringPublisher">
<property name="template" ref="jmsTemplate" />
<property name="destinations">
<list>
<ref local="cscoDest" />
</list>
</property>
</bean>

The above configuration is present in all of my servers.I'm disabling the 'portfolioListener' bean and it's property mapping in 'cscoConsumer' in all the servers except one which is S1 according to the above example.But still messages are being skipped in a round robin fashion.

  • `I have disabled the MessageListener part of all the servers except S1` : How did you disable this ? May be it is not really disabled and thats why you are still seeing round-robin distribution ! – 2020 May 20 '13 at 22:40

2 Answers2

0

"I sense that the queue is distributing the messages in a round robin...".

That cannot happen if there is no active consumer on the other servers; the broker will (can) only send messages when there is a consumer.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • So you mean to say there is no way the queue will send all the messaged to one unique consumer for processing although I disabled all other consumers?I just need one consumer but multiple producers on the same queue. – Sai Chandra Sekhar May 20 '13 at 12:42
  • No; I am saying if the other consumers are disabled the broker WILL send all the messages to the single consumer. – Gary Russell May 20 '13 at 14:39
  • I have added my XML configuration snippet in the thread opener.Please look into it. – Sai Chandra Sekhar May 21 '13 at 06:08
0

I figured it out. My bad. I was only commenting out the 'MessageListener' property from consumers on servers.The key is to disable the following bean -

<bean id="cscoConsumer" class="org.springframework.jms.listener.DefaultMessageListenerContainer102">

Thank you so much Gary for your help.Appreciate it.