diff --git a/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/base/README.tpl.qute.md b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/base/README.tpl.qute.md new file mode 100644 index 00000000000000..405280158877db --- /dev/null +++ b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/base/README.tpl.qute.md @@ -0,0 +1 @@ +{#include readme-header /} \ No newline at end of file diff --git a/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/codestart.yml b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/codestart.yml new file mode 100644 index 00000000000000..f1e942edd7fe58 --- /dev/null +++ b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/codestart.yml @@ -0,0 +1,12 @@ +name: reactive-messaging-codestart +ref: reactive-messaging-codestart +tags: extension-codestart +type: code +metadata: + title: Reactive Messaging codestart + description: Use SmallRye Reactive Messaging to interact with Apache Kafka + related-guide-section: https://quarkus.io/guides/kafka +language: + base: + dependencies: + - io.quarkus:quarkus-smallrye-reactive-messaging \ No newline at end of file diff --git a/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/java/src/main/java/org/acme/MyReactiveMessagingApplication.java b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/java/src/main/java/org/acme/MyReactiveMessagingApplication.java new file mode 100644 index 00000000000000..5a96e456cbc572 --- /dev/null +++ b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/java/src/main/java/org/acme/MyReactiveMessagingApplication.java @@ -0,0 +1,35 @@ +package org.acme; + +import io.quarkus.runtime.StartupEvent; +import org.eclipse.microprofile.reactive.messaging.*; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.event.Observes; +import javax.inject.Inject; +import java.util.stream.Stream; + +@ApplicationScoped +public class MyReactiveMessagingApplication { + + @Inject + @Channel("source") + Emitter emitter; + + /** Sends message to the source channel, can be used from a JAX-RS resource or any bean of your application **/ + void onStart(@Observes StartupEvent ev) { + Stream.of("Hello", "with", "SmallRye", "reactive", "message").forEach(string -> emitter.send(string)); + } + + /** Consume the message from the source channel, uppercase it and send it to the uppercase channel **/ + @Incoming("source") + @Outgoing("uppercase") + public Message toUpperCase(Message message) { + return message.withPayload(message.getPayload().toUpperCase()); + } + + /** Consume the uppercase channel and print the message **/ + @Incoming("uppercase") + public void sink(String word) { + System.out.println(">> " + word); + } +}