May 18th, 2009, 05:30 PM
DefaultMessageListenerContainer with clustering
I am using two activemq servers and connecting to them from Spring using URL
and then registering listener as
<bean class="org.springframework.jms.listener.DefaultMes sageListenerContainer" init-method="start" destroy-method="stop">
<property name="connectionFactory" ref="staticJmsConnectionFactory"/>
<property name="destination" ref="responseQueue"/>
<property name="messageListener" ref="asyncResponseAdapter"/>
<property name="concurrentConsumers" value="1"/>
<property name="sessionTransacted" value="true"/>
However, I am getting connected to only one of the server. If I increase concurrentConsumers to higher value, I see that I am connected to both, but is there a way to connect to both servers with only 1 consumer.
May 20th, 2009, 06:54 PM
No other way
No, there is no other way, the concurrent consumers define the maximum number of consumers that can be created. Since you are not alowing more than one so the first server it is able to connect to, it is going to start listening to it. In case you are using queues then ideally you should eb listening with more consumers to fasten processing.
One more pitfall though, even in case you define say 5 concurrent consumers and now you are listening to both the queues if one of the queues go down then all consumers will gte hooked on to the first server itslef. One needs to use application server setting such as forward messages to members of the same distributed queue to avoid such a situation