Ah, I was missing this out. But I'm still confused about how to handle network failures (and the RabbitMQ server being restarted). Perhaps it would help if I explain my expectation with a simple example:
If I setup the channel and create a queue like this:
=> (def ch (lch/open (rmq/connect {:automatically-recover true})))
...
=> (lq/declare ch "test" :durable true :auto-delete false)
...
I can check that the channel is open and get the status of the queue:
{:message-count 0, :consumer-count 0}
If I stop the RabbitMQ server, I can see that the channel is now closed:
Then, if I start the RabbitMQ server, I can see that the channel is still closed:
And if I try to, say, get the status of a queue, I get an exception back:
AlreadyClosedException clean connection shutdown; reason: Attempt to use closed channel com.rabbitmq.client.impl.AMQChannel.ensureIsOpen (AMQChannel.java:190)
I was expecting the channel to automatically recover, and hence allow me to get the queue status. Shouldn't it?
Incidentally, I think I don't actually need to use the on-recovery callbacks, but if I do set these up, I notice two things:
- The Connection version of on-recovery (`handle-conn-recovery` in my initial example) does get called, but the parameter is an AMQConnection and not, as I was expecting, a com.novemberain.langohr.Channel.
- The Channel version of on-recovery (`handle-ch-recovery` in my initial example) doesn't get called, as I was expecting.
Thanks.