Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » Paho (java) concurrency model(What is the concurrency model underlying Paho (java version)?)
Paho (java) concurrency model [message #1743416] Thu, 15 September 2016 09:14 Go to next message
Alberto Anguita is currently offline Alberto AnguitaFriend
Messages: 4
Registered: September 2016
Junior Member
Hi,

I recently started using the Paho java client. I am using the asynch client. I have searched about the concurrency model used by paho, but I found little info.

- Are received messages handled by a single thread, or one thread per topic, or one thread per message?
- Are published messages queued and processed by a single thread, or are they processed in parallel by different threads?
- May I perform operations on the client in the connect success callback (i.e. subscribe to topics)?
- May I publish a message in the subscribe success callback?

Thanks in advance.

Regards.
Re: Paho (java) concurrency model [message #1744285 is a reply to message #1743416] Fri, 23 September 2016 21:22 Go to previous messageGo to next message
Ian Craggs is currently offline Ian CraggsFriend
Messages: 83
Registered: March 2013
Member
I can give you some answers.

There are multiple threads for each client object: sending thread, receiving thread, callback thread. Despite this I think there are limitations on what operations you can make in the callbacks. I'll ask James to explain further.

Ian
Re: Paho (java) concurrency model [message #1744344 is a reply to message #1743416] Mon, 26 September 2016 08:25 Go to previous messageGo to next message
James Sutton is currently offline James SuttonFriend
Messages: 71
Registered: July 2015
Member
Hi,

1) Received messages are handled by a single thread, keep in mind that the messageArrived callback that you implement will block that thread, so you will want to handle the message quickly (If handling the message may take a while, you might want to pass incoming messages off to a new thread for your application to process)
- See: https://www.eclipse.org/paho/files/javadoc/org/eclipse/paho/client/mqttv3/IMqttMessageListener.html and https://www.eclipse.org/paho/files/javadoc/org/eclipse/paho/client/mqttv3/MqttCallback.html#messageArrived-java.lang.String-org.eclipse.paho.client.mqttv3.MqttMessage-

2) Published messages are handed off to a synchronous thread as well and will be queued and published in order, this is because there is only a single communications thread with direct control of the socket.

3) Yes you can. You won't be blocking anything either.

4) Again, you can, no problems there. You won't be blocking anything either.
Re: Paho (java) concurrency model [message #1744551 is a reply to message #1744344] Wed, 28 September 2016 07:44 Go to previous message
Alberto Anguita is currently offline Alberto AnguitaFriend
Messages: 4
Registered: September 2016
Junior Member
Thank you so much for your answers!
Previous Topic:Connecting to distributed broker
Next Topic:How to NOT acknowledge a message
Goto Forum:
  


Current Time: Tue Sep 24 00:17:59 GMT 2024

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

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

Back to the top