如何使用2条RabbitMQ消息EasyNetQ中的消息

时间:2018-08-09 14:13:52

标签: rabbitmq easynetq

public void InitAmqpConnectionConfiguration()         {             尝试             {                 _connectionConfiguration.Hosts =新列表{new HostConfiguration {Host = _mHost}};                 _connectionConfiguration.UserName = _mUsername;                 _connectionConfiguration.Password = _mPassword;                 _connectionConfiguration.Timeout = 35;             }             捕获(异常e)             {                 Common.LogMessage(“ HandlerMethods.InitAmqpConnectionConfiguration” + e);             }         }

  public void initialiseRabbitMq()
    {
        string strguiMessage = "";

        try
        {
            populateDictionaryItems();
            InitAmqpConnectionConfiguration();

            RabbitMQIBus = RabbitHutch.CreateBus(_connectionConfiguration, RegisterServices);
            RabbitMQAdvancedBus = RabbitHutch.CreateBus(_connectionConfiguration, RegisterServices).Advanced;

            RabbitMQIBus2 = RabbitHutch.CreateBus(_connectionConfiguration, RegisterServices);
            RabbitMQAdvancedBus2 = RabbitHutch.CreateBus(_connectionConfiguration, RegisterServices).Advanced;

              ………….
       }


    public string _mSiteControllerQueue = "myqueue1";
    public string _mSiteControllerQueue2 = "myqueue2";

当我在调试模式下运行下面的代码并单步执行代码时,单步执行该代码只会经过第一个队列,而不是第二个队列。 当我执行“添加监视”以检查“队列”和“队列2”的内容时,将显示队列的详细信息,而不显示队列2的详细信息。 我不确定是否已正确声明队列。

public void InitAmqpReceive(ref String strLogMessage)         {             尝试             {

            var queue = RabbitMQAdvancedBus.QueueDeclare(_mSiteControllerQueue, false, false);
            RabbitMQAdvancedBus.Consume(queue, (body, properties, info) => ProcessMessage(body));

            var queue2 = RabbitMQAdvancedBus2.QueueDeclare(_mSiteControllerQueue2, false, false, false, false, null, null, 255);
            RabbitMQAdvancedBus2.Consume(queue2, (body, properties, info) => ProcessMessage(body));

        }

        catch (Exception e)
        {
            Common.LogMessage("HandlerMethods.InitAmqpReceive" + e);
        }

    }

0 个答案:

没有答案