Пример #1
0
        public MQChannel CreateChannel(string queue, string routeKey, string exchangeType)
        {
            MQConnection     conn    = new MQConnection(this.Config, this.vHost);
            MQChannelManager cm      = new MQChannelManager(conn);
            MQChannel        channel = cm.CreateReceiveChannel(exchangeType, this.Exchange, queue, routeKey);

            return(channel);
        }
Пример #2
0
        /// <summary>
        ///  启动订阅
        /// </summary>
        public void Start()
        {
            if (started)
            {
                return;
            }
            MQConnection     conn    = new MQConnection(this.Config, this.vHost);
            MQChannelManager manager = new MQChannelManager(conn);

            foreach (var item in this.Queue)
            {
                MQChannel channel = manager.CreateReceiveChannel(item.ExchangeType, this.Exchange, item.Queue, item.RouterKey);
                channel.OnReceivedCallBack = item.OnReceived;
                this.Channels.Add(channel);
            }
            started = true;
        }