Skip to content

Instantly share code, notes, and snippets.

@mpilone
Last active August 29, 2015 14:02
Show Gist options
  • Save mpilone/6ceb9ed7b92dd15c44e8 to your computer and use it in GitHub Desktop.
Save mpilone/6ceb9ed7b92dd15c44e8 to your computer and use it in GitHub Desktop.
An example of creating a reliable, distributed, and elastic STOMP server using HazelcastMQ on top of Hazelcast.
HazelcastInstance hazelcast = Hazelcast.newHazelcastInstance();
HazelcastMQConfig mqConfig = new HazelcastMQConfig();
mqConfig.setHazelcastInstance(hazelcast);
HazelcastMQInstance mqInstance = HazelcastMQ.newHazelcastMQInstance(mqConfig);
// Create the server.
HazelcastMQStompConfig stompConfig = new HazelcastMQStompConfig(mqInstance);
HazelcastMQStompInstance stompServer = HazelcastMQStomp.newHazelcastMQStompInstance(stompConfig);
// Create a client.
StompClient stompClient = new StompClient("localhost", stompConfig.getPort());
stompClient.connect();
// Send a message.
Frame frame = FrameBuilder.send("/queue/demo.test", "Hello World!").build();
stompClient.send(frame);
// Sit back and enjoy! More at https://github.com/mpilone/hazelcastmq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment