Python calling broker MQ and DBus

My Python is worse than my Chinese (I have never seen so many smiling faces than when I try to speak Mandarin), so I need a little help:

I want to listen to MQ for something (for topics specified in the configuration) and send a message to dBus and instead listen to dBus (for topics specified in the configuration), and transfer them back to MQ. Due to the fact that my conclusion is Python. I found: MQTT.org PYMQi and Mosquitto .

So the approach seems valid. Now I am looking for code samples. My main task is to make the code efficient. Since it seems that the subroutine should run in the polling loop, how do I do this in Python without linking my system.

+4
source share
4 answers

PYMQi contains a sample code: http://packages.python.org/pymqi/examples.html In order not to interrogate you, you can look at MQ Triggers. They allow you to run the application when a message is queued.

+2
source

You need to clearly indicate whether you are using MQ (WebSphere MQ aka MQSeries) or MQTT aka WebSphere MQ Telemetry.

If you're using MQ, then definitely check out PyMQI, which looks pretty good at this point - here is a recent example on how to use this.

For MQTT, which is a lightweight messaging protocol that can interact with WebSphere MQ with the right components, then the mosquitto project provides the Python API and some examples that use it.

I'm afraid I'm not a Python expert, so I'm not quite sure how you would optimize everything around.

+1
source

I want something to listen to MQ (for those specified in the configuration) and send the message to dBus and [...]

Hi stwissel,

I would also like to mention that the upcoming version of PyMQI 1.2 will provide support for themes and subscriptions. It should be really pretty soon, I fix some test cases literally when we talk. Just thought that I mentioned this in case you are wondering if these MQ functions can be used with PyMQI; Well, not with 1.1, but 1.2 is just around the corner.

Hooray!

+1
source

I believe that you do not need a survey. PyMQI provides read locks (and I think dBus does this too).

If you need to listen to multiple connections at the same time (for example, both dBus and MQ), you should still use blocking reads, simply by executing each of them in a separate thread and, possibly, passing results using something like Python Queue.Queue() . This way you get messages as soon as they arrive, without the delay caused by the polling.

0
source

Source: https://habr.com/ru/post/1337241/


All Articles