Skip to content

Instantly share code, notes, and snippets.

@danielkec
Last active December 7, 2020 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielkec/e44d41a2ec7fd59ee6511423d8aa1ed5 to your computer and use it in GitHub Desktop.
Save danielkec/e44d41a2ec7fd59ee6511423d8aa1ed5 to your computer and use it in GitHub Desktop.
// Manually define JMS connection factory
ActiveMQConnectionFactory connectionFactory =
new ActiveMQConnectionFactory("tcp://192.168.0.123:61616");
// Setup connector
JmsConnector seConn = JmsConnector.builder()
.connectionFactory("jms-con-1", connectionFactory)
.build();
// Prepare channels
Channel<String> toJms = Channel.<String>builder()
.name("to-jms")
.subscriberConfig(JmsConnector.configBuilder()
.queue("example_queue_1")
.namedFactory("jms-con-1")
.build())
.build();
Channel<String> fromJms = Channel.<String>builder()
.name("from-jms")
.publisherConfig(JmsConnector.configBuilder()
.queue("example_queue_1")
.namedFactory("jms-con-1")
.build())
.build();
// Prepare emitter for interaction with non-reactive code
Emitter<String> emitter = Emitter.create(toAq);
// Connect everything together
Messaging.builder()
.connector(seConn)
.emitter(emitter)
.listener(fromAq, s -> {
System.out.println("Message received: " + s);
})
.build()
.start();
// Manually send some messages
emitter.send("Hello");
emitter.send("world");
emitter.send("from");
emitter.send("Active");
emitter.send("MQ!");
// Don't forget to wait for messages to arrive asynchronously!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment