Skip to content

Instantly share code, notes, and snippets.

@matzew
Created December 20, 2018 13:41
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 matzew/09772c7fd877ecfcf3532b8ff305816e to your computer and use it in GitHub Desktop.
Save matzew/09772c7fd877ecfcf3532b8ff305816e to your computer and use it in GitHub Desktop.
package io.smallrye.reactive.messaging.example.eventclouds;
import io.smallrye.reactive.messaging.cloudevents.CloudEventMessage;
import io.smallrye.reactive.messaging.http.HttpMessage;
import org.eclipse.microprofile.reactive.messaging.Incoming;
import org.eclipse.microprofile.reactive.messaging.Message;
import org.eclipse.microprofile.reactive.messaging.Outgoing;
import javax.enterprise.context.ApplicationScoped;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
@ApplicationScoped
public class MyCloudEventProcessor {
// processor from "source" out to (external) http
@Incoming("source")
@Outgoing("to-http")
public HttpMessage<CloudEventMessage> process(CloudEventMessage<String> message) {
return HttpMessage.HttpMessageBuilder.<CloudEventMessage>create()
.withMethod("PUT")
.withPayload(message)
.withHeader("Content-Type", "application/cloudevents+json")
.build();
}
// my HTTP Server
@Incoming("from-http")
public CompletionStage<Void> receive(Message m) {
System.out.println("da -> " + m);
return CompletableFuture.completedFuture(null);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment