Hi alinaqvi! If you’re a Solace customer, you should probably directly email Solace Support for an official answer.
That said, the comment in the code block above does not appear in the Solace documentation. It is true that onComplete() is run asynchronously (i.e. via callback) at the end of a cache response, however the messages from the cache are ordered, and the API would receive the “end of response” message after all the cached messages. And there are not parallel threads within the Java JCSMP API that are dispatching messages… there is one thread (reactor) that reads message from the socket and places them on an internal notification queue, and then another thread (dispatcher) that sends them into the application via callback. It should be the same thread that is running the XMLMessageListener.onReceive() method as the CacheRequestListener.onComplete() method. So the order should be maintained… you’d only get the onComplete() after all the cached messages have been sent to the API. You shouldn’t need to wait for 1 second. That is unless, you are taking messages out of the onReceive() callback and sending them to other worker threads to be processed…?
If not, have you seen or can you prove that cache response messages arrive on the message callback AFTER the onComplete() is run? Obviously, you could be receiving Live Data messages, since you are adding a subscription as part of your cache request. (the true
in the method signature). Do you check if messages are “cached” or “live” messages inside the onReceive()? (XMLMessage.isCacheMessage() ?)
Let us know. Thanks!