I've been searching for quite a while to find a way to do this. So far, all of the solace samples of queue consuming uses either a latch or some sort of thread; https://github.com/SolaceSamples/solace-samples-java/tree/master/src/main/java/com/solace/samples As soon as the latch is removed, nothing is consumed. Is there a way around using latches?
Asked
Active
Viewed 481 times
1 Answers
0
You can use XMLMessageConsumer.receive()
.
Javadocs can be found here.
The Solace Java API allows you to consume messages asynchronously or synchronously. The examples that you are referring to consume messages asynchronously, and make use of an latch to help synchronization between threads.
Note that there are more examples included within the Solace API package. BlockingSubscriber.java
in the API package provides an example of how to receive messages synchronously.

Russell Sim
- 1,693
- 2
- 14
- 22
-
Is there a way to avoid using latches asynchronously? – chey Mar 29 '17 at 13:52
-
Simply remove the latches and ensure that your application does not terminate before receiving messages. Alternatively, you can also refer to the `SimpleFlowToQueue.java` example that bundled together with the API. – Russell Sim Apr 06 '17 at 04:15
-
When I remove the latches, the application terminates right away after start and does not consume anything. Any reasons why this is happening? – chey Apr 10 '17 at 18:10
-
I believe that this is because the Java application is allowed to terminate immediately, without waiting for the received message to arrive. Try adding a delay before the program terminates. – Russell Sim May 25 '17 at 01:17