Exemplo n.º 1
0
        protected Task SendMessage(string routingKey, StandardPayload payload, PayloadHandler replyHandler = null, PayloadHandler timeoutHandler = null, int timeout = StandardPayload.DEFAULT_TIMEOUT)
        {
            if (SMQActorBase.IsDebugMode)
            {
                System.Console.WriteLine(routingKey);
            }

            IBasicProperties props = this.RMQChannel.CreateBasicProperties();

            props.ReplyTo       = "amq.rabbitmq.reply-to";
            props.CorrelationId = payload.PayloadId.ToString();
            var payloadJson = JsonConvert.SerializeObject(payload);

            this.RMQChannel.BasicPublish(this.Microphone, routingKey, props, Encoding.UTF8.GetBytes(payloadJson));
            return(payload.WaitForReply(replyHandler, timeoutHandler, timeout));
        }
        protected Task SendMessage(string routingKey, StandardPayload payload, PayloadHandler replyHandler = null, PayloadHandler timeoutHandler = null, int timeout = StandardPayload.DEFAULT_TIMEOUT, string directMessageQueue = "")
        {
            if (SMQActorBase.IsDebugMode)
            {
                System.Console.WriteLine(routingKey);
            }

            var finalMic       = String.IsNullOrEmpty(directMessageQueue) ? this.Microphone : "";
            var finalRoutinKey = String.IsNullOrEmpty(directMessageQueue) ? routingKey : directMessageQueue;

            IBasicProperties props = this.RMQChannel.CreateBasicProperties();

            props.ReplyTo       = "amq.rabbitmq.reply-to";
            props.CorrelationId = payload.PayloadId.ToString();
            payload.RoutingKey  = String.IsNullOrEmpty(directMessageQueue) ? "" : routingKey;
            var payloadJson = JsonConvert.SerializeObject(payload, new JsonSerializerSettings()
            {
                NullValueHandling = NullValueHandling.Ignore
            });

            this.RMQChannel.BasicPublish(finalMic, finalRoutinKey, props, Encoding.UTF8.GetBytes(payloadJson));
            return(payload.WaitForReply(replyHandler, timeoutHandler, timeout));
        }