Answer the question
In order to leave comments, you need to log in
How to Go way to implement reconnection to RabbitMQ?
Good afternoon. The github.com/streadway/amqp example was taken as a basis , a fragmentary code was found for implementing reconnection to the RabbitMQ node https://gist.github.com/svcavallar/be2d40953eaf278... in case the connection is closed. I tried several options, apparently I fundamentally misunderstand how it should work. As far as I understand, when recreating the amqp.Connect object, it is also necessary to recreate the channel, queue and messages objects. Please show (or correct a piece of code) how such functionality should look like, I attach the code https://gist.github.com/cascad-s/7fca5c68639114eb9... . Thank you in advance.
Answer the question
In order to leave comments, you need to log in
I didn’t read it in detail, but before each one: the rabbitCloseError
channel for notifications about closing the connection needs to be recreated via make .
Proof: https://github.com/streadway/amqp/issues/160
svcavallar does just that:
rabbitConn = connectToRabbitMQ(uri)
rabbitCloseError = make(chan *amqp.Error) // <---- look here
rabbitConn.NotifyClose(rabbitCloseError)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question