I'm using this library for my program. How should I make sure that the channel I'm using for consumption and/or production is still working, before re-initializing it? For example, in ruby, I could simply do:
bunny_client = Bunny.new({....})
bunny_client.start
to start the client, and
if not bunny_client or bunny_client.status != :connected
# re-initialize the client
How to do this with streadway's amqp client?
The QueueDeclare
and QueueInspect
functions may provide equivalent functionality. According to the docs:
Use this method to check how many unacknowledged messages reside in the queue and how many consumers are receiving deliveries and whether a queue by this name already exists.
If the queue by this name exists, use Channel.QueueDeclare check if it is declared with specific parameters.
If a queue by this name does not exist, an error will be returned and the channel will be closed.
QueueDeclare declares a queue to hold messages and deliver to consumers. Declaring creates a queue if it doesn't already exist, or ensures that an existing queue matches the same parameters.
It looks like there's some good info regarding Durable
queues (survive server restarts) in those docs as well.