Beispiel #1
0
        public void SendFileRemovedEvent(IFileRemovedEvent @event)
        {
            _channel.ExchangeDeclare(exchange: RabbitMqConstants.FileRemovedExchange,
                                     type: ExchangeType.Fanout);

            _channel.QueueDeclare(queue: RabbitMqConstants.FileRemovedQueue, durable: false, exclusive: false,
                                  autoDelete: false, arguments: null);
            _channel.QueueBind(queue: RabbitMqConstants.FileRemovedQueue, exchange: RabbitMqConstants.FileRemovedExchange, routingKey: "");

            var serializedCommand = JsonConvert.SerializeObject(@event);

            var properties = _channel.CreateBasicProperties();

            properties.ContentType = RabbitMqConstants.JsonMimeType;

            _channel.BasicPublish(exchange: RabbitMqConstants.FileRemovedExchange, routingKey: "",
                                  basicProperties: properties,
                                  body: Encoding.UTF8.GetBytes(serializedCommand));
        }
 public void Consume(IFileRemovedEvent command)
 {
     GlobalHost.ConnectionManager.GetHubContext <FileHub>().Clients.All
     .sendFileProcessed(command.Client, command.DocumentName);
 }