StompClient client = new StompClient("stomp://" + url.getHost());
client.connect();
final Set<String> outbound = new HashSet<String>();
final CountDownLatch outboundLatch = new CountDownLatch(2);
SubscriptionBuilder builder = client.subscribe(DESTINATION_QUEUE_ONE);
builder.withMessageHandler(new MessageHandler() {
public void handle(StompMessage message) {
String content = message.getContentAsString();
outbound.add(content);
outboundLatch.countDown();
}
});
ClientSubscription subscription = builder.start();
client.send(StompMessages.createStompMessage(DESTINATION_QUEUE_ONE, "msg1"));
client.send(StompMessages.createStompMessage(DESTINATION_QUEUE_ONE, "msg2"));
Assert.assertTrue("No latch timeout", outboundLatch.await(10, TimeUnit.SECONDS));