public void PublishRegisteredNotification(IOrderRegistered order) { channel.ExchangeDeclare( exchange: RabbitMqConstants.OrderRegisteredExchange, type: ExchangeType.Fanout); channel.QueueDeclare( queue: RabbitMqConstants.OrderRegisteredNotificationQueue, durable: false, exclusive: false, autoDelete: false, arguments: null); channel.QueueBind( queue: RabbitMqConstants.OrderRegisteredNotificationQueue, exchange: RabbitMqConstants.OrderRegisteredExchange, routingKey: ""); var serializedOrder = JsonConvert.SerializeObject(order); var messageProperties = channel.CreateBasicProperties(); messageProperties.ContentType = RabbitMqConstants.JsonMimeType; channel.BasicPublish( exchange: RabbitMqConstants.OrderRegisteredExchange, routingKey: "", basicProperties: messageProperties, body: Encoding.UTF8.GetBytes(serializedOrder)); }
public void SendOrderRegisteredEvent(IOrderRegistered command) { channel.ExchangeDeclare( exchange: RabbitMqConstants.GetOrderRegisteredExchange(), type: ExchangeType.Fanout); var serializedCommand = JsonConvert.SerializeObject(command); var messageProperties = channel.CreateBasicProperties(); messageProperties.ContentType = RabbitMqConstants.JsonMimeType; channel.BasicPublish( exchange: RabbitMqConstants.GetOrderRegisteredExchange(), routingKey: "", basicProperties: messageProperties, body: Encoding.UTF8.GetBytes(serializedCommand)); }
public void Consume(IOrderRegistered registered) { //Send notification to user Console.WriteLine($"Customer notification sent: Order id {registered.OrderId} registered"); }