ActiveMQ - CreateSession failover timeout after a connection is resumed

梦想与她 提交于 2019-12-11 00:38:43

问题


I'm using ActiveMQ 5.6.0 and ActiveMQ NMS client.

I connect to the broker using the follow code:

var connectionFactory = new ConnectionFactory(
    "failover:(tcp://localhost:61616)?transport.timeout=5000"
    );

connection = connectionFactory.CreateConnection();    
connection.Start();

connection.ConnectionResumedListener += OnConnectionResumed;

Then I stop the broker and start it again. After that in the method OnConnectionResumed

private void OnConnectionResumed()
{
    var session = connection.CreateSession();

    ...
}

I always get the failover timeout exception when try to create a session.

What am I doing wrong?

Thanks


回答1:


This problem appeared because I had created a session in the thread where the resumed call is made in.

The correct code is:

private void OnConnectionResumed()
{
    Task.Factory.StartNew(() =>
        {
            var session = connection.CreateSession();

            ...
        });
}


来源:https://stackoverflow.com/questions/11775741/activemq-createsession-failover-timeout-after-a-connection-is-resumed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!