Пример #1
0
 private Task Publish(Enveloppe env)
 {
     using (var connection = GetConnection())
     {
         using (var channel = GetChannel(connection))
         {
             var body  = Encoding.UTF8.GetBytes(env.ToJson());
             var props = GetBasicProperties(channel, env);
             channel.BasicPublish(
                 exchange: _configuration.Emiter + "_events",
                 routingKey: "",
                 basicProperties: props,
                 body: body);
         }
     }
     return(Task.CompletedTask);
 }
Пример #2
0
        private Task Publish(Enveloppe env)
        {
            using (var connection = GetConnection())
            {
                using (var channel = GetChannel(connection))
                {
                    var body  = Encoding.UTF8.GetBytes(env.ToJson());
                    var props = GetBasicProperties(channel, env);

                    channel.BasicPublish(
                        exchange: _configuration.Emiter + "_commands",
                        routingKey: env.AssemblyQualifiedDataType.Split('.')[0],
                        basicProperties: props,
                        body: body);
                }
            }
            return(Task.CompletedTask);
        }
Пример #3
0
        private Task Publish(Enveloppe env, string routingKey)
        {
            using (var connection = GetConnection())
            {
                using (var channel = GetChannel(connection))
                {
                    var body  = Encoding.UTF8.GetBytes(env.ToJson());
                    var props = GetBasicProperties(channel, env);

                    foreach (var cfg in configuration.NetworkInfos.ServiceExchangeDescriptions
                             .Where(s => (s.ExchangeContentType & ExchangeContentType.Event) != 0))
                    {
                        channel.BasicPublish(
                            exchange: cfg.ExchangeName,
                            routingKey: routingKey,
                            basicProperties: props,
                            body: body);
                    }
                }
            }
            return(Task.CompletedTask);
        }