qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robbie Gemmell <robbie.gemm...@gmail.com>
Subject Re: Connecting to durable consumer - Qpid Proton Python.
Date Wed, 15 Feb 2017 11:26:06 GMT
On 15 February 2017 at 11:06, Jeremy Gooch <goochjs@yahoo.co.uk.invalid> wrote:
> Hi Gordon,
> Many thanks - I thought it would be simple.  Did I miss where this is documented?
> With the change you've suggested in place, I notice that the subscription is only durable
when I ctrl-C my script.  If it finishes normally then the subscription seems to be deleted.
 Presumably this is a feature of Proton.  What do I need to do so that my script can exit
elegantly but still leave the subscription in place?  Do I need to do something in the "on_disconnected"
> J.

You are presumably closing the receiver (in AMQP terms, detaching the
receiving link with 'closed=true') somewhere in your code, an action
which explicitly ends the subscription on the broker. You need to
either detach the receiver without closing it, or simply close the
session or connection without doing anything to the receiver which
will implicitly detach it and should leave the subscription in place,
the same as exiting the process without doing any of these does.

>       From: Gordon Sim <gsim@redhat.com>
>  To: users@qpid.apache.org
>  Sent: Wednesday, 15 February 2017, 10:47
>  Subject: Re: Connecting to durable consumer - Qpid Proton Python.
> On 15/02/17 09:05, Jeremy Gooch wrote:
>> Hi,
>> I'm trying to get a Qpid Proton Python v3.4 client to subscribe to an ActiveMQ broker
over AMQP v1.0 as a durable consumer.  I can create a durable subscription but don't quite
understand how to pick up the same subscription the next time my script runs.
>> After each run, the ActiveMQ admin console shows that a durable subscription has
been created, and it is named according to my script's input.  The subscription works correctly,
in that it receives messages even after my script has ended.  When I next execute the script,
however, it just creates a new subscription rather than connect to the one previously created.I
think I might need to set a "ClientID" (as ActiveMQ calls it) against the subscription but
I don't understand the syntax to use.
> Set the container_id on the container before the connect, e.g.
>   event.container.container_id = "my-client-id"
>> Here's the bit of my code that creates the connection:-def on_start(self, event):
>>    if self.subscription_name:
>>        logging.debug("Naming durable subscription " + self.subscription_name)
>>        durable = DurableSubscription()
>>    else:
>>        logging.debug("Subscription will not be durable")
>>        durable = None
>>    messaging_connection = event.container.connect(self.url)
>>    logging.info(messaging_connection.clientID)
>>    event.container.create_receiver(
>>        messaging_connection,
>>        self.resource,
>>        name=self.subscription_name,
>>        options=durable
>>    )
>>    logging.debug("Connected to " + self.url + "/" + self.resource)
>> Thanks,Jeremy.
>> Jeremy Gooch http://goochgooch.co.uk
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org

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

View raw message