I write simple nms listener with failover. Then I start my app without AciteMQ started, my app start to create failover threads. And do it until I start ActiveMQ.
My Spring config:
Code:
<object id="connectionFactory" type="Spring.Messaging.Nms.Connections.CachingConnectionFactory, Spring.Messaging.Nms">
<property name="SessionCacheSize" value="10" />
<property name="TargetConnectionFactory">
<object type="Apache.NMS.ActiveMQ.ConnectionFactory, Apache.NMS.ActiveMQ">
<constructor-arg index="0" value="activemq:failover:(tcp://localhost:61616)?transport.timeout=1000&transport.startupMaxReconnectAttempts=1"/>
</object>
</property>
</object>
<object name="nmsTemplate" type="Spring.Messaging.Nms.Core.NmsTemplate, Spring.Messaging.Nms">
<property name="ConnectionFactory" ref="connectionFactory"/>
<property name="DefaultDestinationName" value="foo.bar"/>
</object>
<object id="controller" type="Consumer.Controller, Consumer" init-method="Init">
<constructor-arg ref="nmsTemplate" />
</object>
Listener creation:
Code:
public void Init()
{
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
container.ConcurrentConsumers = 10;
container.ConnectionFactory = NmsOperations.ConnectionFactory;
container.DestinationName = "foo.bar";
container.MessageListener = new MessageListener(this, NmsOperations);
try
{
container.AfterPropertiesSet();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}