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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to