@Target(value={METHOD,ANNOTATION_TYPE}) @Retention(value=RUNTIME) @MessageMapping @Documented public @interface StreamListener
EnableBinding
(e.g. channels).
Annotated methods are allowed to have flexible signatures, which determine how the
method is invoked and how their return results are processed. This annotation can be
applied for two separate classes of methods.
StreamListenerParameterAdapter
.
Only declarative methods can have binding targets or conversion targets as arguments
and return type.
Declarative methods must specify what inputs and outputs correspond to their arguments
and return type, and can do this in one of the following ways.
Input
or Output
annotation for each of the
parameters and the Output
annotation on the method for the return type (if
applicable). The use of annotations in this case is mandatory. In this case the
StreamListener
annotation must not specify a value.Input
bound target as the annotation value of
StreamListener
and using
SendTo
@StreamListener
public @Output("joined") Flux<String> join(
@Input("input1") Flux<String> input1,
@Input("input2") Flux<String> input2) {
// ... join the two input streams via functional operators
}
An example of declarative method signature using the latter idiom is as follows:
@StreamListener(Processor.INPUT)
@SendTo(Processor.OUTPUT)
public Flux<String> convert(Flux<String> input) {
return input.map(String::toUppercase);
}
Declarative methods are invoked only once, when the context is refreshed.
MessageMapping
.
If the method returns a Message
, the result will
be automatically sent to a binding target, as follows:
Message
will be sent
as-isMessage
MessageHeaders
of the resulting
message.SendTo
annotation, if
present{@code
MessageMapping}
,
EnableBinding}
,
org.springframework.messaging.handler.annotation.SendTo}
@AliasFor(value="target") public abstract String value
@AliasFor(value="value") public abstract String target
public abstract String condition
boolean
value.Copyright © 2017 Pivotal Software, Inc.. All rights reserved.