Пример #1
0
        public Task PublishAsync(string topic, IRemoteEventData remoteEventData)
        {
            Logger.Debug($"{_producer.Name} producing on {topic}");

            var deliveryReport = _producer.ProduceAsync(topic, null, _remoteEventSerializer.Serialize(remoteEventData));

            return(deliveryReport.ContinueWith(task =>
            {
                Logger.Debug($"Partition: {task.Result.Partition}, Offset: {task.Result.Offset}");
            }));
        }
Пример #2
0
        public void Publish(string topic, IRemoteEventData remoteEventData)
        {
            var connection = _connectionPool.Acquire();

            try
            {
                var channel = connection.CreateModel();
                channel.ExchangeDeclare(_exchangeTopic, "topic", true);
                var body       = Encoding.UTF8.GetBytes(_remoteEventSerializer.Serialize(remoteEventData));
                var properties = channel.CreateBasicProperties();
                properties.Persistent = true;
                channel.BasicPublish(_exchangeTopic, topic, properties, body);
            }
            finally
            {
                _connectionPool.Return(connection);
            }
        }
Пример #3
0
 public void Publish(string topic, IRemoteEventData remoteEventData)
 {
     _database.Publish(topic, _remoteEventSerializer.Serialize(remoteEventData));
 }