Hi Alan Antonuk.
Thank you very much for the hint!
By the way, the library allows us to read messages from a broker, by means of the c instruction : amqp_consume_message(Conn, &Envelope, TimeVal, 0);.
In my project I use 10 seconds for TimeVal. So, after 10 seconds without reading messages (queue is empty), the code doesn't stay blocked by amqp_consume_message. As the amqp_consume_message is part of a while(true) scope, it is executed again and again. It is ok for me.
However, there is some situations I don know how to recover from that.
While my system is running, whether the broker is stopped and restarted (rabbitmqctl stop_app; rabbitmqctl start_app), my system enters in a AMQP_STATUS_UNEXPECTED_STATE !
How to recover from that state and how to put my system reading messages again, via C code? That is, how to recover from AMQP_STATUS_UNEXPECTED_STATE without reset my system?
I also would like to do my system recover from another abnormal situation: AMQP_STATUS_HEARTBEAT_TIMEOUT . So, how to simulate and recover from these situations.
Just one more question: is there a kind of situation that can let my system blocked in amqp_consume_message forever? I guess so, that is why I use the TimeVal.
Any hit/example will be very helpful.
However, if I'm doing/thinking something wrong, tell me, please!
Best Regards!
RODRIGO PIMENTA CARVALHO
Inatel Competence Center
Software
Ph:
+55 35 3471 9979 (Brasil)
________________________________________
De:
rabbitm...@googlegroups.com [
rabbitm...@googlegroups.com] em Nome de Alan Antonuk [
alan.a...@gmail.com]
Enviado: quarta-feira, 10 de setembro de 2014 12:03
Para: Rodrigo Pimenta Carvalho
Cc:
rabbitm...@googlegroups.com
Assunto: Re: [rabbitmq-users] Rabbitmq-C : How to recover from AMQP_STATUS_CONNECTION_CLOSED situation programmatically?
You need to call amqp_destroy_connection() to destroy the existing connection, then reconnect to the broker as you did initially. rabbitmq-c does not provide any connection state recovery, though it isn't impossible to write some code to accomplish this depending on your use case.
-Alan
On Tue, Sep 9, 2014 at 6:46 AM, Rodrigo Pimenta Carvalho <
pim...@inatel.br<mailto:
pim...@inatel.br>> wrote:
Hi.
Let's suppose the broker rabbitmq crashed, while it was being used to enqueue messages.
In this case, the client application get the AMQP_STATUS_CONNECTION_CLOSED status.
In addiction, let's suppose there is a program that observes the broker and restarts it always when necessary.
In this scenario, the crash condition will be just temporarily. So, the client application should try to reconnect to the broker, after a while, and recover from this AMQP_STATUS_CONNECTION_CLOSED situation.
How to recover from the AMQP_STATUS_CONNECTION_CLOSED situation programmatically, by means of the rabbitmq-c library and C code?
Any hint will be very helpful.
Thanks alot.
RODRIGO PIMENTA CARVALHO
Inatel Competence Center
Software
Ph:
+55 35 3471 9979<tel:%2B55%2035%203471%209979>