[rabbitmq-discuss] EventMachine EM::Iterator being blocked with rabbitmq rbc

Michael Klishin michael.s.klishin at gmail.com
Sun Jan 8 20:46:42 GMT 2012


Paul Cowan:

> Spinning up a new thread was the answer to my problem:
> 
>               Thread.new do
>                 5.times do
>                   lead = get_lead(n, (n == 5))
> 
>                   puts "message #{n} is_last = #{lead.is_last} at #{Time.now}";
>                 
>                   AMQP::Exchange.default.publish(
>                                                   MultiJson.encode(lead), 
>                                                   :routing_key => header.reply_to,
>                                                   :correlation_id => header.correlation_id
>                                                 )
>                 
>                   n += 1
>                   sleep(2)
>                 end
>               end

Paul,

Keep in mind that channels should not be shared between threads. I just checked the source and AMQP::Exchange.default called w/o argument opens a new channel every time but I still wanted to
remind about this.

Sharing channels used for publishing between threads may result in frames being delivered out of order.

MK




More information about the rabbitmq-discuss mailing list