3

I have .Net client for ActiveMQ. I'm using Apache.NMS 1.5.1.2739 and Apache.NMS.ActiveMQ 1.5.6.2746

I connect to the broker using the follow code:

var connectionFactory = new ConnectionFactory("failover:tcp://127.0.0.1:61616/?transport.timeout=5000");
IConnection connection = connectionFactory.CreateConnection();
connection.Start();

The problem is when there is no ActiveMQ broker available then connection.Start() hangs forever. So transport.timeout doesn't help here. I want to have timeout for Start() method. So after this period of time exception occurs and execution may proceed further. How to avoid such an issue?

Pashec
  • 23,199
  • 3
  • 26
  • 26
  • possible duplicate of [ActiveMQ NMS: connection.start() hangs with Failover protocol when broker is down](http://stackoverflow.com/questions/10880814/activemq-nms-connection-start-hangs-with-failover-protocol-when-broker-is-dow) – ecatmur Sep 20 '12 at 08:55

1 Answers1

5

I've found right uri parameters. The entire uri should look like this one

failover:(tcp://127.0.0.1:61616/)?transport.startupMaxReconnectAttempts=2

But be aware if exception occurs then ActiveMQ client will not try to reconnect any more and you need to do it yourself.

Pashec
  • 23,199
  • 3
  • 26
  • 26