public void Add(ulong publishTag, BatchPublish batchPublish)
        {
            _published.AddOrUpdate(publishTag, key => batchPublish, (key, existing) =>
            {
                existing.NotConfirmed($"Duplicate key: {key}");

                return(batchPublish);
            });

            batchPublish.SetPublishTag(publishTag);
        }
示例#2
0
        public Task Publish(string exchange, string routingKey, bool mandatory, IBasicProperties basicProperties, byte[] body, bool awaitAck)
        {
            if (mandatory)
            {
                return(_immediatePublisher.Publish(exchange, routingKey, true, basicProperties, body, awaitAck));
            }

            var publish = new BatchPublish(exchange, routingKey, basicProperties, body, awaitAck);

            async Task PublishAsync()
            {
                await _publishChannel.Writer.WriteAsync(publish).ConfigureAwait(false);

                await publish.Confirmed.ConfigureAwait(false);
            }

            return(PublishAsync());
        }