Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » can you support max_packets of loop(timeout=1.0, max_packets=1)?
can you support max_packets of loop(timeout=1.0, max_packets=1)? [message #1722880] Wed, 10 February 2016 01:07 Go to next message
Masahiro Ohkawa is currently offline Masahiro OhkawaFriend
Messages: 2
Registered: February 2016
Junior Member
One of my program with Paho is to receive messages of multiple topics. Processing each topic takes different time, so is each message in a topic.
To handle multiple messages in parallel, multiple processes are introduced.
Therefore each process receive only one message to handle it. After finishing handling it, such process wants to receive another message. (i.e. PULL model)
To do this, I want Paho to support max_packets of loop(timeout=1.0, max_packets=1).
If there is alternative idea, please let me know.

My proposal is to set None to max_packets as default. If it's None, max_packets is set as it is currently. If the max_packets is set explicitly, use the value.

Thanks,
Re: can you support max_packets of loop(timeout=1.0, max_packets=1)? [message #1723781 is a reply to message #1722880] Wed, 17 February 2016 21:23 Go to previous messageGo to next message
Masahiro Ohkawa is currently offline Masahiro OhkawaFriend
Messages: 2
Registered: February 2016
Junior Member
For just one message to be pulled, just need to disconnect when receiving another message on "on_message"?
I tried it using Mosquitto, and it worked in most cases.
But in some cases, all messages remaining in MQTT seem to be lost, though publishing additional messages after that seems to work fine.
Re: can you support max_packets of loop(timeout=1.0, max_packets=1)? [message #1724200 is a reply to message #1723781] Mon, 22 February 2016 09:47 Go to previous message
James Sutton is currently offline James SuttonFriend
Messages: 71
Registered: July 2015
Member
Hi,

The issue that you will run into with multiple processes with the same topics is that they will all receive the same messages, so you will get duplicates. If processing incoming messages takes time, I would suggest multi-threading your application. When a message arrives, stick it on a queue on a separate thread that can process it. That way you will not block paho from receiving messages and you will also reduce the risk of loosing or duplicating messages. It means you can take your time processing incoming data and could even attach multiple threads to the same queue meaning that you could process many messages in parallel. Something like this (in java) http://www.rgagnon.com/javadetails/java-0555.html or this (in python) http://www.ibm.com/developerworks/aix/library/au-threadingpython/
Previous Topic:deadlock with the java client
Next Topic:Android App crashes when inactive due to wrong function call in AlarmPingSender
Goto Forum:
  


Current Time: Thu Apr 25 22:32:00 GMT 2024

Powered by FUDForum. Page generated in 0.03075 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top