Skip to content

Instantly share code, notes, and snippets.

@danielkec
Last active December 7, 2020 12:50
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/faf5be213a9f9ae364709981845f9ec4 to your computer and use it in GitHub Desktop.
Save danielkec/faf5be213a9f9ae364709981845f9ec4 to your computer and use it in GitHub Desktop.
// Setup connector
JmsConnector seConn = JmsConnector.create();
// Prepare channels
Channel<String> toJms = Channel.create("to-jms");
Channel<String> fromJms = Channel.create("from-jms");
// Prepare emitter for interaction with non-reactive code
Emitter<String> emitter = Emitter.create(toJms);
// Connect everything together
Messaging.builder()
.config(Config.builder()
.sources(() -> FileConfigSource.builder()
.path(Paths.get("src/main/resources/application.yaml"))
.build()
)
.build()
)
.connector(seConn)
.emitter(emitter)
.listener(fromJms, 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