Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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