[ https://issues.apache.org/jira/browse/PROTON-2469?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17448713#comment-17448713 ]
Gordon Sim commented on PROTON-2469: ------------------------------------ The issue here is the broker. It does not recognise amq.topic/com.product.sample. It does however support the subject binding filter. To do so you would use something like: {noformat} from proton import Described, symbol from proton.handlers import MessagingHandler from proton.reactor import Container, Filter broker_url = "192.168.80.81:5672" topic = "amq.topic" class SubjectFilter(Filter): def __init__(self, value): super(SubjectFilter, self).__init__(\{symbol('subject-filter'): Described(symbol('apache.org:legacy-amqp-topic-binding:string'), value)}) class Client(MessagingHandler): def __init__(self, broker_url, topic): super(Client, self).__init__() self.broker_url = broker_url self.topic = topic def on_start(self, event): conn = event.container.connect(self.broker_url) self.receiver = event.container.create_receiver( conn, self.topic, options=SubjectFilter("com.product.sample")) def on_message(self, event): print(event.message.body) Container(Client(broker_url, topic)).run() {noformat} > How to use proton-python properly to receive messages > ----------------------------------------------------- > > Key: PROTON-2469 > URL: https://issues.apache.org/jira/browse/PROTON-2469 > Project: Qpid Proton > Issue Type: Bug > Components: python-binding > Reporter: Andreas Waider > Priority: Major > > My configuration: > Running qpidd on host: 192.168.80.81 with following exchanges (`qpid-config > exchanges`): > ``` > Type Exchange Name Attributes > ================================================== > direct --replicate=none > direct amq.direct --durable --replicate=none > fanout amq.fanout --durable --replicate=none > headers amq.match --durable --replicate=none > topic amq.topic --durable --replicate=none > direct qmf.default.direct --replicate=none > topic qmf.default.topic --replicate=none > topic qpid.management --replicate=none > ``` > I have multiple producers publishing to the topics like > `amq.topic/com.product.sample1`, `amq.topic/com.product.sample2`, you get the > pattern. > I can receive all messages from the producers by running `qpid-receive -b > 192.168.80.81 -a amq.topic/com.product.sample1 -f` on the commandline. > But when it comes to implementing this in Python using the > [python-qpid-proton](https://pypi.org/project/python-qpid-proton/) library > (version 0.35.0) it wont work as needed. This is my python file to receive > messages on a specific topic: > ``` > from proton.handlers import MessagingHandler > from proton.reactor import Container > broker_url = "192.168.80.81:5672" > topic = "amq.topic/com.product.sample" > class Client(MessagingHandler): > def __init__(self, broker_url, topic): > super(Client, self).__init__() > self.broker_url = broker_url > self.topic = topic > def on_start(self, event): > conn = event.container.connect(self.broker_url) > self.receiver = event.container.create_receiver( > conn, self.topic, dynamic=True) > def on_message(self, event): > print(event.message.body) > Container(Client(broker_url, topic)).run() > ``` > Can anyone help me and point me to where my mistake is? Help is much > appreciated! -- This message was sent by Atlassian Jira (v8.20.1#820001) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org For additional commands, e-mail: dev-h...@qpid.apache.org