Rawat Rawat - 4 months ago 57
Java Question

MessageArrived MQTT paho library

hi guys i am a beginner and i am trying to implement paho library my paho client receives messages in messageArrived on particular topics and i read that messageArrived functions are synchronous, means one at a time? right !

problem is my tomcat stops sometime i have to restart it and i see a log in catalina.err

The web application [] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation.

and my process are a bit long i think cause i have to check message according to my requirement and i also tried to create some alert SMS with them in te same function so may be this take some time.

so how should i manage it, am i right? or completely a wrong guess??

any suggestion will be great.


The correct way to handle long running tasks that consume MQTT messages is to create a threadpool and and pass off processing of those messages to the threadpool from the onMessageArrived() method.

The java.util.concurrent.ThreadPoolExecutor is probably your best starting point.