You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by "ONeil, Jerome" <je...@Wabtec.com> on 2022/04/28 20:48:30 UTC

Python Proton Binding on Receiver for Broker

Hello,

I am trying to set up a receiver for a topic on a qpid C++ broker and need to control the binding between the Source exchange and the receiver queue.  I can get a simple receiver set up just fine and pull messages from it.

>>> event.container.create_receiver("amqp://localhost/MyTopic")

[jerome@localhost ~]$ qpid-config -r queues
Queue 'debug-MyTopic'
    bind [#] => MyTopic


So that's grand.  I need to control the binding with more detail, though, and for the life of me I can't figure out how to do it.  I've tried controlling on the URL.  I've tried Filters and Selectors.  I have tried a variety of different link and receiver properties (x-bindings, etc..) and other methods scrapped up from the internet, and all I ever get for that binding is '#'.

Can someone provide a simple example?  Lets say I wanted that binding to actually be

bind [jerome.#] => MyTopic

What would that look like?  I am all out of clues and hope someone has one to spare.

Best regards,

-Jerome
This email and any attachments are only for use by the intended recipient(s) and may contain legally privileged, confidential, proprietary or otherwise private information. Any unauthorized use, reproduction, dissemination, distribution or other disclosure of the contents of this e-mail or its attachments is strictly prohibited. If you have received this email in error, please notify the sender immediately and delete the original. Neither this information block, the typed name of the sender, nor anything else in this message is intended to constitute an electronic signature unless a specific statement to the contrary is included in this message.

RE: [EXTERNAL]: Re: Python Proton Binding on Receiver for Broker

Posted by "ONeil, Jerome" <je...@Wabtec.com>.
Hey Steve,

Thanks for the reply.  I’m pretty sure I’ve extracted that code a few times, too.  😃

I’d really like to do this all in Proton, though, for a couple reasons.  Using a single library is on the list somewhere, and it will run in a pretty restricted environment.   And also right up until now I kind of like the Proton API.   It is really concise, and who doesn’t love callbacks?

Best regards,

-J

From: Steve Huston <sh...@riverace.com>
Sent: Thursday, April 28, 2022 2:19 PM
To: users@qpid.apache.org
Subject: [EXTERNAL]: Re: Python Proton Binding on Receiver for Broker

Hi Jerome, You can do that with the Python QMF API. I extracted the below from another script so it may need some adjustments but should get you there. -Steve import os import sys from qpid import * import qpid.messaging host="localhost" port=5672 ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
Please use caution responding to this email or opening any attachments.
ZjQcmQRYFpfptBannerEnd

Hi Jerome,



You can do that with the Python QMF API. I extracted the below from another script so it may need some adjustments but should get you there.

-Steve



import os

import sys



from qpid import *

import qpid.messaging



host="localhost"

port=5672

sock = util.connect(host, port)

qmf_con = connection.Connection(sock)

qmf_con.start()

session = qmf_con.session(str(qpid.messaging.uuid4()), timeout=30)



session.queue_declare(queue="MyTopic")

session.exchange_bind(queue="MyTopic", exchange="whatever", binding_key="jerome.#")

session.sync

session.close(timeout=10)





On 4/28/22, 4:48 PM, "ONeil, Jerome" <je...@Wabtec.com>> wrote:



    Hello,



    I am trying to set up a receiver for a topic on a qpid C++ broker and need to control the binding between the Source exchange and the receiver queue.  I can get a simple receiver set up just fine and pull messages from it.



    >>> event.container.create_receiver("amqp://localhost/MyTopic")



    [jerome@localhost ~]$ qpid-config -r queues

    Queue 'debug-MyTopic'

        bind [#] => MyTopic





    So that's grand.  I need to control the binding with more detail, though, and for the life of me I can't figure out how to do it.  I've tried controlling on the URL.  I've tried Filters and Selectors.  I have tried a variety of different link and receiver properties (x-bindings, etc..) and other methods scrapped up from the internet, and all I ever get for that binding is '#'.



    Can someone provide a simple example?  Lets say I wanted that binding to actually be



    bind [jerome.#] => MyTopic



    What would that look like?  I am all out of clues and hope someone has one to spare.



    Best regards,



    -Jerome

    This email and any attachments are only for use by the intended recipient(s) and may contain legally privileged, confidential, proprietary or otherwise private information. Any unauthorized use, reproduction, dissemination, distribution or other disclosure of the contents of this e-mail or its attachments is strictly prohibited. If you have received this email in error, please notify the sender immediately and delete the original. Neither this information block, the typed name of the sender, nor anything else in this message is intended to constitute an electronic signature unless a specific statement to the contrary is included in this message.



This email and any attachments are only for use by the intended recipient(s) and may contain legally privileged, confidential, proprietary or otherwise private information. Any unauthorized use, reproduction, dissemination, distribution or other disclosure of the contents of this e-mail or its attachments is strictly prohibited. If you have received this email in error, please notify the sender immediately and delete the original. Neither this information block, the typed name of the sender, nor anything else in this message is intended to constitute an electronic signature unless a specific statement to the contrary is included in this message.

Re: Python Proton Binding on Receiver for Broker

Posted by Steve Huston <sh...@riverace.com>.
Hi Jerome,

You can do that with the Python QMF API. I extracted the below from another script so it may need some adjustments but should get you there.
-Steve

import os
import sys

from qpid import * 
import qpid.messaging

host="localhost"
port=5672
sock = util.connect(host, port)
qmf_con = connection.Connection(sock)
qmf_con.start()
session = qmf_con.session(str(qpid.messaging.uuid4()), timeout=30)

session.queue_declare(queue="MyTopic")
session.exchange_bind(queue="MyTopic", exchange="whatever", binding_key="jerome.#")
session.sync
session.close(timeout=10)


On 4/28/22, 4:48 PM, "ONeil, Jerome" <je...@Wabtec.com> wrote:

    Hello,

    I am trying to set up a receiver for a topic on a qpid C++ broker and need to control the binding between the Source exchange and the receiver queue.  I can get a simple receiver set up just fine and pull messages from it.

    >>> event.container.create_receiver("amqp://localhost/MyTopic")

    [jerome@localhost ~]$ qpid-config -r queues
    Queue 'debug-MyTopic'
        bind [#] => MyTopic


    So that's grand.  I need to control the binding with more detail, though, and for the life of me I can't figure out how to do it.  I've tried controlling on the URL.  I've tried Filters and Selectors.  I have tried a variety of different link and receiver properties (x-bindings, etc..) and other methods scrapped up from the internet, and all I ever get for that binding is '#'.

    Can someone provide a simple example?  Lets say I wanted that binding to actually be

    bind [jerome.#] => MyTopic

    What would that look like?  I am all out of clues and hope someone has one to spare.

    Best regards,

    -Jerome
    This email and any attachments are only for use by the intended recipient(s) and may contain legally privileged, confidential, proprietary or otherwise private information. Any unauthorized use, reproduction, dissemination, distribution or other disclosure of the contents of this e-mail or its attachments is strictly prohibited. If you have received this email in error, please notify the sender immediately and delete the original. Neither this information block, the typed name of the sender, nor anything else in this message is intended to constitute an electronic signature unless a specific statement to the contrary is included in this message.


Re: Python Proton Binding on Receiver for Broker

Posted by Gordon Sim <gs...@redhat.com>.
On Thu, Apr 28, 2022 at 9:58 PM ONeil, Jerome <je...@wabtec.com> wrote:
> So that's grand.  I need to control the binding with more detail, though, and for the life of me I can't figure out how to do it.  I've tried controlling on the URL.  I've tried Filters and Selectors.  I have tried a variety of different link and receiver properties (x-bindings, etc..) and other methods scrapped up from the internet, and all I ever get for that binding is '#'.
>
> Can someone provide a simple example?  Lets say I wanted that binding to actually be
>
> bind [jerome.#] => MyTopic
>
> What would that look like?  I am all out of clues and hope someone has one to spare.

Attached is an example that sets the topic binding.