Reputation: 45
I currently have my paho-MQTT client script with a message queue and a on_message callback function.
def on_message(self, client, _, message):
message = message.payload.decode()
self.messageQueue.put_nowait(message)
i need to do some processing on these received messages (I get around 12 messages in the queue every 3 seconds)
how can i process these messages safely ?
Upvotes: 0
Views: 608
Reputation: 820
If you want a robust distributed queue mechanism, you can implement using python celery where your on_message would act as a producer which placed task on broker. And multiple workers/consumers would be running on different machines and consuming tasks from broker.
Link: http://docs.celeryproject.org/en/latest/getting-started/introduction.html
Hope this helps!
Upvotes: 0