示例#1
0
        /// <summary>
        /// 生产者发布字符串
        /// </summary>
        static void PublishString()
        {
            IProducer producer = SingleConnectionTool.Connection.CreateProducer("TestExchange");//此处是交换机名称

            while (true)
            {
                string msg = Console.ReadLine();
                if ("quit".Equals(msg))
                {
                    // 退出要把所有资源都关闭

                    producer.Close();
                    SingleConnectionTool.Close();

                    return;
                }

                producer.Publish(msg, "TestKey1");//此处是绑定key
            }
        }
        /// <summary>
        /// 生产者发布字符串
        /// </summary>
        static void PublishString()
        {
            //IProducer producer = SingleConnectionTool.Connection.CreateProducer("TestExchange");//此处是交换机名称
            var       conn     = SingleConnectionTool.CreateConnectionFromConfigName("MessageQueue:RabbitConnectionString_vtest");
            IProducer producer = conn.CreateProducer("TestExchange2");//此处是交换机名称

            while (true)
            {
                string msg = Console.ReadLine();
                if ("quit".Equals(msg))
                {
                    // 退出要把所有资源都关闭

                    producer.Close();
                    SingleConnectionTool.Close();

                    return;
                }

                producer.Publish(msg, "TestKey1");//此处是绑定key
            }
        }
示例#3
0
 public void Dispose()
 {
     // Close queue interfaces
     _actionRequestConsumer.Close();
     _actionResponseProducer.Close();
 }