-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix #20872 * created `MyReactiveMessagingApplication` to demonstrates `@Emitter`, `@Incoming` and `@Outgoing` annotations.
- Loading branch information
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...arkus/extension-codestarts/reactive-messaging-codestart/base/README.tpl.qute.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{#include readme-header /} |
12 changes: 12 additions & 0 deletions
12
...ources/codestarts/quarkus/extension-codestarts/reactive-messaging-codestart/codestart.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
35 changes: 35 additions & 0 deletions
35
...ctive-messaging-codestart/java/src/main/java/org/acme/MyReactiveMessagingApplication.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> 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<String> toUpperCase(Message<String> 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); | ||
} | ||
} |