Пример #1
0
        private void PublishResponseToConsumer(byte[] replyBody, IBasicProperties requestProps,
                                               IDictionary <string, object> headers = null)
        {
            headers = headers ?? new Dictionary <string, object>();
            string brokerName = requestProps.GetBrokerName();

            using (var replychannel = _connMgr.CreateChannel(brokerName))
            {
                IBasicProperties replyProps = replychannel.CreateBasicProperties();
                replyProps.ContentType   = requestProps.ContentType;
                replyProps.CorrelationId = requestProps.CorrelationId;
                replyProps.Headers       = headers;

                IBasicProperties replyprops = replychannel.CreateBasicProperties();

                replychannel.BasicPublish(exchange: "",
                                          routingKey: requestProps.ReplyTo,
                                          basicProperties: replyProps,
                                          body: replyBody);
            }
        }