Skip to content

Instantly share code, notes, and snippets.

@danielkec
Created January 24, 2021 13:57
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/8a9866aee25096d054cdc7b5bfa1fbd4 to your computer and use it in GitHub Desktop.
Save danielkec/8a9866aee25096d054cdc7b5bfa1fbd4 to your computer and use it in GitHub Desktop.
final SubmissionPublisher<CloudEvent> emitter = new SubmissionPublisher<>();
@Outgoing("to-stream")
public PublisherBuilder<CloudEvent> registerEmitter() {
return ReactiveStreams.fromPublisher(FlowAdapters.toPublisher(emitter));
}
@POST
@Path("/send/{msg}")
public void send(@PathParam("msg") String payload) {
CloudEvent cloudEvent = eventTemplate
.withId(UUID.randomUUID().toString())
.withData(MediaType.TEXT_PLAIN, payload.getBytes())
.build();
emitter.submit(cloudEvent);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment