Exemple #1
0
        private void Publish(IMessageContract message, Guid correlationId)
        {
            var props = channel.CreateBasicProperties();

            props.CorrelationId = correlationId.ToString();
            props.ReplyTo       = responseQueueName;

            var body = message.Serialize();

            logger.LogInformation($"Sending {message?.MessageType} message with CorrelationId {correlationId}");
            channel.BasicPublish(string.Empty, requestQueueName, props, body);
        }
Exemple #2
0
        private void PublishResponse(IMessageContract responseValue, string correlationId, string responseQueueName)
        {
            try
            {
                var body = responseValue.Serialize();

                var responseProps = channel.CreateBasicProperties();
                responseProps.CorrelationId = correlationId;

                channel.BasicPublish(string.Empty, responseQueueName, responseProps, body);

                Console.WriteLine($"Sending {responseValue?.MessageType} response with CorrelationId {correlationId}");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error occurred during sending message with a {correlationId} correlationId - {ex.Message}");
            }
        }