【问题标题】:ActiveMQ - CreateSession failover timeout after a connection is resumedActiveMQ - 连接恢复后的 CreateSession 故障转移超时
【发布时间】:2012-07-31 07:44:47
【问题描述】:

我正在使用 ActiveMQ 5.6.0 和 ActiveMQ NMS 客户端。

我使用以下代码连接到代理:

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

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

connection.ConnectionResumedListener += OnConnectionResumed;

然后我停止代理并重新启动它。之后在 OnConnectionResumed 方法中

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

    ...
}

我在尝试创建会话时总是遇到故障转移超时异常。

我做错了什么?

谢谢

【问题讨论】:

    标签: c# activemq


    【解决方案1】:

    出现这个问题是因为我在线程中创建了一个会话 已恢复通话。

    正确的代码是:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-22
      • 1970-01-01
      • 2014-01-21
      • 1970-01-01
      • 2011-10-13
      • 1970-01-01
      • 2019-05-01
      • 2012-01-15
      相关资源
      最近更新 更多