【问题标题】:Apache.NMS.NMSConnectionException: 'Error connecting to activemqhost:61616.'Apache.NMS.NMSConnectionException:“连接到 activemqhost 时出错:61616。”
【发布时间】:2021-01-22 00:34:59
【问题描述】:

我在 .NET Framework 4.7.2 中有控制台项目,它安装了 Apache.NMS 和 Apache.NMS.ActiveMQ 包。我从official documentation 复制并粘贴示例代码,当我运行它时,它遇到错误Apache.NMS.NMSConnectionException: 'Error connecting to activemqhost:61616.' SocketException

这是我的代码:

class Program
{
    public static void Main(string[] args)
    {
        // Example connection strings:
        //    activemq:tcp://activemqhost:61616
        //    stomp:tcp://activemqhost:61613
        //    ems:tcp://tibcohost:7222
        //    msmq://localhost

        Uri connecturi = new Uri("activemq:tcp://activemqhost:61616");

        Console.WriteLine("About to connect to " + connecturi);

        // NOTE: ensure the nmsprovider-activemq.config file exists in the executable folder.
        IConnectionFactory factory = new NMSConnectionFactory(connecturi);

        using (IConnection connection = factory.CreateConnection())
        {

        }
    }
}

下面是我的activemq.xml

   <transportConnectors>
        <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
        <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    </transportConnectors>

【问题讨论】:

    标签: c# activemq


    【解决方案1】:

    我用了这个连接字符串Uri connecturi = new Uri("tcp://localhost:61616");后解决了

    【讨论】:

      猜你喜欢
      • 2013-08-21
      • 2017-01-02
      • 2018-09-06
      • 2016-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-04
      • 2015-01-12
      相关资源
      最近更新 更多