Пример #1
0
        /// <summary>
        /// 消息发送
        ///
        /// 【必填】withMessage指定消息
        ///
        /// 【必填】withReceiver指定接收者以便发送到属于接受者的消息,格式请查MqEnum中注释(依赖于withType传入类型)
        ///
        /// 【非必填】withType指定消息类型 默认1对1
        /// </summary>
        public void SendMessage()
        {
            ValidateSendParams();

            string routingKey = GetPublishRoutingKey();

            string queue = "publish_" + Config.MqConfig.AppID + "_" + type.ToString().ToLower();

            MqCore.GetInstance().Publish(type.ToString().ToLower(), queue, message, routingKey);
        }
Пример #2
0
        /// <summary>
        /// 消息监听
        ///
        /// 【必填】withListening指定接收事件
        ///
        /// 【必填】withReceiver指定接收者以便收到属于这个接受者的消息,格式请查MqEnum中注释(依赖于withType传入类型)
        ///
        /// 【非必填】withType指定消息类型 默认1对1
        /// </summary>
        public void Listening()
        {
            ValidateLesteningParams();

            List <string> listRoutingKey = GetListeningRoutingKey(type);

            string queue = "listening_" + Config.MqConfig.AppID + "_" + type.ToString().ToLower() + "_" + receiver;

            MqCore mqCore = new MqCore();

            mqCore.MessageListening += listening;

            mqCore.Subscribe(type.ToString().ToLower(), queue, listRoutingKey);
        }