Issue with amqp_consume_message and library error

41 views
Skip to first unread message

TauCeti

unread,
Jan 2, 2025, 9:30:35 AMJan 2
to rabbitmq-c-users

I'm working with AMQP in C++ and rabbitmq and I'm having trouble handling errors when consuming messages. Here is the relevant part of my code:

amqp_rpc_reply_t reply = amqp_consume_message(connection_->getConnection(), &envelope, NULL, 0); if (reply.reply_type != AMQP_RESPONSE_NORMAL) { std::cerr << "Error receiving message: " << amqp_error_string2(reply.reply_type) << std::endl; if (reply.library_error) { std::cerr << "Library error: " << amqp_error_string(reply.library_error) << std::endl; } }

When I run this code, I sometimes encounter library errors, but I'm not sure how to properly handle them. Should I throw an exception, close the connection and attempt a reconnect, or is there another recommended approach?

Any insights or examples would be greatly appreciated.

Thanks in advance!

Reply all
Reply to author
Forward
0 new messages