On 05/22/2013 03:03 PM, Christian Fromme wrote:
Hello Qpid users,

I am wondering if there is a way to make subscriptions ("push queues")
durable via the C++ API. With "durable", I mean:

1. Process foo subscribes for messages using SubscriptionManager
implementing MessageListener to broker x
2. Broker x restarts at some point.
3. Process foo does not need to subscribe again.

Using Google to find information about the topic, it looks like this
is possible in the Java API. Checking the SubscriptionManager and
MessageListener classes API it doesn't look like it is possible in
C++. Am I missing something?

If this isn't possible, is there at least a way to get informed when
the broker isn't available anymore so I can maybe restart the
subscriber thread or something?

First, I would not advise you to start developing against the qpid::client API as it is old, AMQP 0-10 specific and more complicated to use. Instead look at the qpid::messaging API.

In qpid::messaging you subscribe by creating a receiver on the session, passing in an address to identify the source of messages and optionally some further properties for the subscription.

Where you need to ensure that you receive all messages, even if temporarily disconnected (e.g. through client or network failure), you need to specify a subscription name (this needs to be unique) and mark the queue as durable:

  my-topic; {link:{durable:True, name:'my-subscription'}}

and/or reliable:

  my-topic; {link:{reliability:at-least-once, name:'my-subscription'}}

Note that in this case you need an explicit close of the receiver in order to cancel the subscription. You may want additionally to ensure that if disconnected for a certain amount of time, the subscription queue will get deleted by the broker. E.g. to ensure that if disconnected for more than 30 seconds the subscription is cleaned up you could use:

my-topic; {link:{reliability:at-least-once, name:'my-subscription', x-declare:{auto-delete:True, arguments:{'qpid.auto_delete_timeout':30}}}}

In addition to that, you can configure the connection to automatically reconnect (and automatically re-establish existing sessions and subscriptions) if the connection is lost. You do that by setting the 'reconnect' option on the connection.

There is a little introduction to the messaging API here: http://qpid.apache.org/books/0.20/Programming-In-Apache-Qpid/html/

I hope this helps, please do ask further questions if not!

--Gordon.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to