Reputation: 1424
When you add a @ServiceActivator annotation on a method, that method can have different return types which seem to have different implications for the service:
@ServiceActivator(inputChannel = "..", outputChannel = "..")
public T messageReceiver() {...}
Where T could be
void
Object
MessageHandler
How does the ServiceActivator differ based on the return type? I am specifically wondering about the line in the docs that says:
Return values from the annotated method may be of any type. If the return value is not a Message, a reply Message will be created with that object as its payload.
But I'm not following this because I've seen people return MessageHandlers from their ServiceActivator-annotated methods, and they don't want their MessageHandlers to be wrapped as a payload right?
Like this:
@Bean
@ServiceActivator(inputChannel = "sendAsyncChannel", autoStartup="false")
public MessageHandler sendAsyncHandler() {
return // some MessageHandler
}
Upvotes: 3
Views: 4799
Reputation: 121442
What you are pointing is a Messaging Annotations on @Bean
. This is a bit different story and it implies not related to POJO method invocation aspect.
We use that @ServiceActivator
on the MessageHandler
@Bean
to register an EventDrivenConsumer
endpoint for the provided MessageHandler
, when the POJO method style, creates a MethodInvokingMessageHandler
for the marked with this @ServiceActivator
method.
Please, see more info in the Reference Manual:
Upvotes: 3