The Spring Framework has a Java Stomp Client [1] (since 4.2).
@Test
public void test() throws Exception {
Reactor2TcpStompClient stompClient = new Reactor2TcpStompClient("127.0.0.1", 61613);
stompClient.setMessageConverter(new StringMessageConverter());
final CountDownLatch latch = new CountDownLatch(1);
StompSessionHandler handler = new StompSessionHandlerAdapter() {
@Override
public void afterConnected(StompSession session, StompHeaders connectedHeaders) {
session.send("/queue/stompQ", "foo");
session.subscribe("/queue/stompQ", this);
}
@Override
public void handleFrame(StompHeaders headers, Object payload) {
System.out.println(payload);
latch.countDown();
}
};
stompClient.connect(handler);
assertTrue(latch.await(10, TimeUnit.SECONDS));
stompClient.shutdown();
}
Rabbit creates the queue in this case; see the rabbit docs about the stomp plugin [3].
For a higher-level abstraction, Spring Integration has channel adapters that sit on top of the Spring client [2].