Uploaded image for project: 'Qpid Proton'
  1. Qpid Proton
  2. PROTON-2469

How to use proton-python properly to receive messages

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Feedback Received
    • None
    • None
    • python-binding
    • None

    Description

      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!

      Attachments

        Activity

          People

            Unassigned Unassigned
            a-waider Andreas Waider
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: