cloudamqp / amqp-client.rb

Modern AMQP 0-9-1 Ruby client
https://cloudamqp.github.io/amqp-client.rb/
MIT License
19 stars 6 forks source link

Allow high level operations inside subscribe #19

Closed sinecode closed 2 years ago

sinecode commented 2 years ago

closes #18

Currently, it's not possible to call any high level operations inside the subscribe block. The program halts and it never goes on.

This is due to the fact that all the high-level methods perform the logic inside the same with_connection do. This makes sense for all the operations on the "publish channel" instantiated in client.rb:63:

conn.channel(1) # reserve channel 1 for publishes

But for the .subscribe operation a new channel is created, so I think that is OK to use another block. So in my proposed solution I create another SizedQueue used by the .subscribe method, with the corresponding with_subscribe_connection block.

Note that the underline connection is the same, I'm not creating a new connection.

carlhoerberg commented 2 years ago

The test case is not failing without the patch, what's required is worker_threads: 0..