eclipse-paho / eclipse-paho/paho.mqtt.java
About the processing capacity of paho client
- Dominant language
- Java
- Stars
- 2.3k
- Forks
- 919
- PR merge metrics
- No merged PRs in 30d
Description
Please fill out the form below before submitting, thank you!
- [√] Bug exists Release Version 1.2.0 ( Master Branch)
- [√] Bug exists in Snapshot Version 1.2.1-SNAPSHOT (Develop Branch)
Hi, there are some questions obout the processing capacity of paho client!
**Description:**
mqtt server send messages to paho, and the rate is 10M Bytes/s[sending ten thousand messages per second, the size of each message is 1kb ].But,paho only can receive two thousand messages. If we reduce the sending rate of the mqtt server, paho can receive all messages. After our tests, paho can receive messages as the speed of 1.7M Byte/s. How do you improve the peformance of paho?
**Our code:**
We implements the interface MqttCallbackExtended
`public class App implements MqttCallbackExtended{}`
And,
`private MqttAsyncClient client =new MqttAsyncClient(broker, productId, persistence
,new TimerPingSender(),Executors.newScheduledThreadPool(20));`
We use the callback function messageArrived to count the numbers of the received messages
`synchronized public int add(){
count++;
return count;
}
`
` public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception {
if (count == 0){
time = System.currentTimeMillis();
}
count=add();
logger.info(Thread.currentThread().getName()+"=====[{}]seconds,Receving[{}]messages====",(System.currentTimeMillis()-time)/1000,count);
}`
**The possible reasons:**
By reading the source code, we think that the receive and calling callbacks function are divided into two threads, but the callback has only one thread, which can lead to insufficient performance.
How can we resolve this problem? We hope to get your idea.
Thanks!
Contributor guide
Assessment
This issue has not been assessed yet.