@Target(value={METHOD,ANNOTATION_TYPE}) @Retention(value=RUNTIME) @Documented public @interface StreamEmitter
EnableBinding (e.g. channels).
This annotation is intended to be used in a Spring Cloud Stream application that
requires a source to write to one or more Outputs using the reactive paradigm.
No Inputs are allowed on a method that is annotated with StreamEmitter.
Depending on how the method is structured, there are some flexibility in how the
Output may be used.
Here are some supported usage patterns:
A StreamEmitter method that has a return type cannot take any method parameters.
@StreamEmitter
@Output(Source.OUTPUT)
public Flux<String> emit() {
return Flux.intervalMillis(1000)
.map(l -> "Hello World!!");
}
The following examples show how a void return type can be used on a method with
StreamEmitter and how the method signatures could be used in a flexible manner.
@StreamEmitter
public void emit(@Output(Source.OUTPUT) FluxSender output) {
output.send(Flux.intervalMillis(1000)
.map(l -> "Hello World!!"));
}
@StreamEmitter
@Output(Source.OUTPUT)
public void emit(FluxSender output) {
output.send(Flux.intervalMillis(1000)
.map(l -> "Hello World!!"));
}
@StreamEmitter
public void emit(@Output("OUTPUT1") FluxSender output1,
@Output("OUTPUT2") FluxSender output2,
@Output("OUTPUT3)" FluxSender output3) {
output1.send(Flux.intervalMillis(1000)
.map(l -> "Hello World!!"));
output2.send(Flux.intervalMillis(1000)
.map(l -> "Hello World!!"));
output3.send(Flux.intervalMillis(1000)
.map(l -> "Hello World!!"));
}
Copyright © 2019 Pivotal Software, Inc.. All rights reserved.