You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Christian Fromme <ka...@strace.org> on 2013/05/22 16:03:28 UTC

Durable subscriptions in C++ API?

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?

TIA,
Christian

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Durable subscriptions in C++ API?

Posted by Christian Fromme <ka...@strace.org>.
Hi Gordon,

On Wed, May 22, 2013 at 4:54 PM, Christian Fromme <ka...@strace.org> wrote:
> On Wed, May 22, 2013 at 4:16 PM, Gordon Sim <gs...@redhat.com> wrote:
>
>> 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.
>
> I ended up using the qpid::client API because I didn't find a way to
> subscribe to get messages pushed to a process via the qpid::messaging
> API. Looking at it again after your advice now, I still don't really
> know what to do. I see the routines you described, but how do I
> register a callback or what interface do I need to implement in order
> to get new messages pushed? Could you maybe point me to an example
> please?

I just found this:
http://qpid.2158936.n2.nabble.com/Best-Practices-for-C-API-td7481171.html

And it sounds like there is no "push" style subscription in the
qpid::messaging API (sad face). I'll take a look at the example you've
attached back then.

Christian

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Durable subscriptions in C++ API?

Posted by Christian Fromme <ka...@strace.org>.
On Wed, May 22, 2013 at 4:16 PM, Gordon Sim <gs...@redhat.com> wrote:

> 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.

I ended up using the qpid::client API because I didn't find a way to
subscribe to get messages pushed to a process via the qpid::messaging
API. Looking at it again after your advice now, I still don't really
know what to do. I see the routines you described, but how do I
register a callback or what interface do I need to implement in order
to get new messages pushed? Could you maybe point me to an example
please?

Thanks again,
Christian

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Durable subscriptions in C++ API?

Posted by Gordon Sim <gs...@redhat.com>.
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: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org