Exemplo n.º 1
0
        public MqChannel CreateChannel(string queue, string routeKey, string exchangeType)
        {
            var conn    = new MqConnection(Config, VHost);
            var cm      = new MqChannelManager(conn);
            var channel = cm.CreateReceiveChannel(exchangeType, Exchange, queue, routeKey);

            return(channel);
        }
Exemplo n.º 2
0
        /// <summary>
        ///  启动订阅
        /// </summary>
        public void Start()
        {
            if (Started)
            {
                return;
            }

            var conn    = new MqConnection(Config, VHost);
            var manager = new MqChannelManager(conn);

            foreach (var item in Queues)
            {
                var channel = manager.CreateReceiveChannel(item.ExchangeType, Exchange, item.Name, item.RouterKey);
                channel.OnReceived = item.OnReceived;
                Channels.Add(channel);
            }
            Started = true;
        }