Please explain how to configure a Java client to read from two different RabbitMQ exchanges without polling. I would like the client to awaken when a message arrives, then block again.
In my little system integration problem, one RabbitMQ exchange carries work messages using a variety of routing keys (I know how to use wildcards to catch them), and the other exchange carries control messages (e.g., "stop"). So my client has to listen to messages from both places. This is a relatively low-volume system problem, I'm not asking about load sharing or fairness etc.
Sure I could run a thread that polls each exchange, sleeps, dispatches, forever. But I would like to avoid polling.
I'm somehow reminded of the Unix select() system call that awakens when data is ready on any of the file descriptors handed to it. Does RabbitMQ have something similar?
My current solution is an adapter that spins up a thread to block on each input exchange; upon receipt each thread writes to a java.util.concurrent collection; and I use yet another thread to block on that collection and deliver messages as they arrive to the ultimate consumer. It works fine but if I can chop out this complexity, that would be great.
These SO posts dance around the issue, please feel free to rub my nose in the solution if I've overlooked it in these posts:
For java: RabbitMQ by Example: Multiple Threads, Channels and Queues
For C#: Reading from multiple queues, RabbitMQ
Thanks in advance.