RabbitMQ .NET client async producer support?

271 views
Skip to first unread message

Ping

unread,
Apr 28, 2018, 4:37:01 PM4/28/18
to rabbitmq-users
Hi,

Is async producer supported in RabbitMQ .NET? I cannot find vis google.

Please provide links, or code example, if available.

Async Consumer is available:

Ping

unread,
Apr 28, 2018, 5:43:51 PM4/28/18
to rabbitmq-users
What about async support for Publisher Conformer?

Michael Klishin

unread,
Apr 28, 2018, 11:29:10 PM4/28/18
to rabbitm...@googlegroups.com
Publishing as well as publisher confirms are entirely asynchronous in the protocol.
.NET client allow for server-sent confirms to be handled via event handlers. I'm not sure
how the entire thing can be "more asynchronous".

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
MK

Staff Software Engineer, Pivotal/RabbitMQ

Ping

unread,
Apr 29, 2018, 9:36:44 AM4/29/18
to rabbitmq-users
Hi MK,

I meant .NET await and async API.

Can you answer the questions below:

1. Is WaitForConfirmsOrDie() blocked until confirms arrive? If so, is an async version of it possible?

2. Similarly, is it an async version of BasicPublish possible? 

            var factory = new ConnectionFactory() {
                HostName = _appSetting.MessagingServerSetting.ServerName,
                UserName = _appSetting.MessagingServerSetting.UserName,
                Password = _appSetting.MessagingServerSetting.Password,               
            };
            using (var connection = factory.CreateConnection())
            using (var channel = connection.CreateModel())
            {
                channel.QueueDeclare(
                    queue: QUEUE_NAME,
                    durable: true,
                    exclusive: false,
                    autoDelete: false,
                    arguments: null);         

                //3
                channel.BasicAcks += Channel_BasicAcks; 

                //1
                channel.ConfirmSelect();

                var properties = channel.CreateBasicProperties();
                properties.Persistent = true;

  
         
                    channel.BasicPublish(
                    exchange: "",
                    routingKey: QUEUE_NAME,
                    basicProperties: properties,
                    body: ConvertMessageToByte(message));
                    
                    //2
                    channel.WaitForConfirmsOrDie();
                
            }


On Sunday, April 29, 2018 at 4:29:10 AM UTC+1, Michael Klishin wrote:
Publishing as well as publisher confirms are entirely asynchronous in the protocol.
.NET client allow for server-sent confirms to be handled via event handlers. I'm not sure
how the entire thing can be "more asynchronous".
On Sat, Apr 28, 2018 at 9:43 PM, Ping <pingpongo...@gmail.com> wrote:
What about async support for Publisher Conformer?


On Saturday, April 28, 2018 at 9:37:01 PM UTC+1, Ping wrote:
Hi,

Is async producer supported in RabbitMQ .NET? I cannot find vis google.

Please provide links, or code example, if available.

Async Consumer is available:

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Michael Klishin

unread,
Apr 29, 2018, 9:44:23 AM4/29/18
to rabbitm...@googlegroups.com
There is none. [1] is a relevant discussion (that yielded no consensus in a few years).


To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Michael Klishin

unread,
Apr 29, 2018, 9:45:50 AM4/29/18
to rabbitm...@googlegroups.com
1. As the name suggests it will block. There are event handlers for acks and nacks as I already mentioned.
2. Again, what would a "more async" version look like? Publishing is 100% asynchronous in the protocol. There is no response to wait for whatsoever.

On Sun, Apr 29, 2018 at 8:36 AM, Ping <pingpongo...@gmail.com> wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Message has been deleted

Ping

unread,
Apr 29, 2018, 11:19:36 AM4/29/18
to rabbitmq-users
Can you provide the exact comment for no consensus on the link below, as it is a long page.?

https://github.com/rabbitmq/rabbitmq-dotnet-client/issues/83

So it seems channel.WaitForConfirmsOrDie() might cause performance hit, as it is blocked waiting.

Ping

unread,
Apr 29, 2018, 11:36:22 AM4/29/18
to rabbitmq-users
BasicPublish() might be blocked waiting for response from server. Thus, an async version of it could improve performance.

Michael Klishin

unread,
Apr 30, 2018, 12:21:35 AM4/30/18
to rabbitm...@googlegroups.com
IModel#WaitForConfirmsOrDie blocks until acknowledgements for all outstanding publishes arrive.
That does cause a "performance hit".

There is a different way to handle confirms which was mentioned before in this thread.

IModel#BasicPublish is not blocked by anything. As I said, there is no response in the protocol for
clients who issue basic.publish methods to wait for.

Before you claim that "an async version could improve performance" please first check whether you underdstand
how things actually work. There cannot be a "more async version" of IModel#BasicPublish as far as the protocol is concerned.
There may be a slightly more efficient way of doing things I/O-wise but the publishing method does not wait for anything
on the happy code path.

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages