コード例 #1
0
ファイル: SimpleMQ.cs プロジェクト: Aqmic/Dcp.Lib
        public override void Send(MQMessage mQMessage, Action <MQMessage> callBackAction)
        {
            IBasicProperties properties = this.Channel.CreateBasicProperties();

            if (mQMessage.Response != null)
            {
                properties.ReplyTo = mQMessage.Response.ResponseQueue;
            }
            properties.DeliveryMode    = base.MQConfig.IsDurable ? ((byte)2) : ((byte)1);
            properties.ContentEncoding = this._encoding.EncodingName;
            if (!string.IsNullOrEmpty(mQMessage.MsgId))
            {
                properties.MessageId = mQMessage.MsgId;
            }
            if (!string.IsNullOrEmpty(mQMessage.Label))
            {
                properties.CorrelationId = mQMessage.Label;
            }
            IModelExensions.BasicPublish(this.Channel, null, null, properties, mQMessage.ToData());
            if ((mQMessage.Response != null) && (this.Consumer == null))
            {
                this.Consumer = new EventingBasicConsumer(this.Channel);
                IModelExensions.BasicConsume(this.Channel, mQMessage.Response.ResponseQueue, false, this.Consumer);
                if (callBackAction != null)
                {
                    this.Consumer.Received += (obj, ee) =>
                    {
                        if (callBackAction != null)
                        {
                            this.CallBack(obj, ee, callBackAction);
                        }
                    };
                }
            }
        }
コード例 #2
0
ファイル: RouterMQ.cs プロジェクト: Aqmic/Dcp.Lib
        public override void Send(byte[] body, string label = null)
        {
            IBasicProperties properties = this.Channel.CreateBasicProperties();

            properties.DeliveryMode    = base.MQConfig.IsDurable ? ((byte)2) : ((byte)1);
            properties.ContentEncoding = this._encoding.EncodingName;
            if (label != null)
            {
                properties.CorrelationId = label;
            }
            IModelExensions.BasicPublish(this.Channel, base.MQConfig.Exchange, base.MQConfig.ConsumerID, properties, body);
        }