SimpleAmqpClient - exception handling

831 views
Skip to first unread message

Kim Tran

unread,
Sep 18, 2014, 6:21:15 PM9/18/14
to rabbitm...@googlegroups.com, alan.a...@gmail.com
Alan,
First of all, thanks for the C++ Client library. It hides a bunch of
details that one has to deal with if using rabbitmq-c. SimpleAmqpClient
has good documentation and a number of good examples of how to use
classes/objects provided by the library to do messaging. However, it
seems little is described in terms of exception handling. Is there a
guidelines on how to handle various exceptions that could be thrown by
the library? For example, what can be restarted/reset within the
application vs giving up ? What are the differences between
ChannelException and ConnectionException? Is there a need to have
specific handling for low-level exception like ResourceLockedException?
How should they be handled ?

Thanks,
-Kim


Alan Antonuk

unread,
Sep 19, 2014, 12:01:07 AM9/19/14
to Kim Tran, rabbitm...@googlegroups.com
On Thu, Sep 18, 2014 at 3:21 PM, Kim Tran <ktra...@gmail.com> wrote:
Alan,
First of all, thanks for the C++ Client library.  It hides a bunch of details that one has to deal with if using rabbitmq-c. SimpleAmqpClient has good documentation and a number of good examples of how to use classes/objects provided by the library to do messaging.  However, it seems little is described in terms of exception handling.  Is there a guidelines on how to handle various exceptions that could be thrown by the library?
Unfortunately not, and looking at the exception contract with a more experienced eye; admittedly it's a bit of a mess. But heres where it stands:

ConnectionException (and sub-classes): this maps to an AMQP connection exception. If you see one of these your AmqpClient::Channel object is no longer connected to the broker. You should destroy the Channel object and create a new one.

ChannelException (and sub-classes): this maps to an AMQP channel exception. If you see one of these the last operation you performed on the AmqpClient::Channel object failed. The Channel object itself is still valid, you can continue to use it.

AmqpLibraryException and AmqpResponseLibraryException (they are pretty well the same thing): this wraps a rabbitmq-c library error. From SimpleAmqpClient perspective, if you see one of these, the connection is dead or in an indeterminate state, you should destroy the AmqpClient::Channel objects and start anew.

BadUriException - only thrown from one of the AmqpClient::Channel::Create* functions. No new connection will be returned.

ConnectionClosedException - should be thrown if an AmqpClient::Channel that is closed is used.

ConsumerCancelledException - thrown if the consumer is closed while waiting for a message. Consumer is closed, but AmqpClient::Channel object is still valid.

ConsumerTagNotFound - thrown if you pass a consumer tag that is invalid. AmqpClient::Channel object is still valid.

MessageReturnedException - thrown if you publish with the mandatory flag set, but the message isn't routed to a queue. AmqpClient::Channel object is still valid.

HTH
-Alan

Kim Tran

unread,
Sep 19, 2014, 2:49:40 PM9/19/14
to Alan Antonuk, rabbitm...@googlegroups.com
Thanks Alan!
Those are very useful.
-Kim

Suri MS

unread,
Nov 12, 2018, 11:22:16 PM11/12/18
to rabbitmq-users
Hello Alan,

Can you please help with:
How can we explicitly destroy a channel object in the C++ client ?

Thanks,
Suri

Suri MS

unread,
Nov 16, 2018, 9:11:13 PM11/16/18
to rabbitm...@googlegroups.com
Hi,

Could some expert, please , help me with the query?

Thanks in advance,
Suri

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages