Last active
December 7, 2020 14:03
-
-
Save danielkec/e44d41a2ec7fd59ee6511423d8aa1ed5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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