I have one servlet having void service method that publishes MQTT msg to broker and servlet contains msgArrived function as followsusing MTQTT paho library)
now i want to get this received msg and transfer it to another servlet as response which is making this servlet a request. But service method of this servlet ends before it receives a msg from broker hence it is transferring null response . How can we acheive this. can we use synchronize method somehow so that service method of this servlet waits for the response from broker and then send response to another servlet.
Queue/message are intended to be asynchronous because they take some time. A better approach would be to use an AJAX call on your web page to check if it is done and then redirect to another page. This also lets you show progress.
Alternatively, you change the code to not use the queue.