[rabbitmq-discuss] Difference between async connection using ioloop and blocking connection for rabbitmq

Ask Solem ask at rabbitmq.com
Thu Mar 7 13:25:15 GMT 2013


On Mar 5, 2013, at 11:14 PM, Ameya Patil <Ameya.Patil at servicenow.com> wrote:

> Hi, 
> 
> Ioloops in async connection is exhibiting blocking semantics. I am trying to understand how this is different than a blocking connection
> 
> The documentation (https://pika.readthedocs.org/en/latest/connecting.html#io-and-event-looping ) states:
> These IOLoops are blocking methods which loop and listen for events.
> 
> In a experiment I conducted, I publish 2 messages, each 5 times: message 'test' published by AsyncPublisher and 'test1' by AsyncPublisher1.py.  
> 
> In the consumer I have an if block stating:
> If body == test: 
>    Time.sleep(10)
> 
> I run AsyncPublisher.py first, and after it has sent 5 test messages I run AsyncPublisher1.py.
> 
> The output I expect is :
> Test
> test1
> test1
> test1
> tes1
> Test
> Test
> Test
> Test
> 

Why do you expect this particular order?

> Instead I get:
> Test
> Tes
> Test
> Test
> Test
> test1
> test1
> test1
> test1
> test1
> 
> This is the same as if I would run the sender and receiver using a blocking connection.
> My question is how does a blocking connection different than ioloop.start ? Does it differ only on multithreading ? 
> 

It uses Async I/O, not multithreading, so a single process would not run anything in parallel, but it enables you to do multiple I/O operations at the same time by scheduling
the callbacks for when the operation can be completed.  See http://en.wikipedia.org/wiki/Asynchronous_I/O


More information about the rabbitmq-discuss mailing list