italktothewind
italktothewind

Reputation: 2195

Why there is no @OutboundChannelAdapter annotation in Spring Integration?

1) I would like to create a bean of HttpRequestExecutingMessageHandler (outbound channel adapter for HTTP) and specify the channel via an annotation like @OutboundChannelAdapter, why this is not possible? I suppose there is some design decision that I'm not understanding.

2) What is the suggested way of define HttpRequestExecutingMessageHandler without using XML configuration files? Do I have to configure the bean and set it manually?

Thanks in advance.

Upvotes: 1

Views: 1154

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121177

The @ServiceActivator fully covers that functionality. Unlike @Transformer it doesn't require a return value. So, your POJO method can be just void and the flow is going to stop there similar way a <outbound-channel-adapter> does that in XML configuration.

But in case of HttpRequestExecutingMessageHandler we need to worry about some extra option to make it one-way and stop there without care about any HTTP reply.

So, for the HttpRequestExecutingMessageHandler you need to declare a bean like:

@Bean
@ServiceActivator(inputChannel = )
public HttpRequestExecutingMessageHandler httpRequestExecutingMessageHandler() {
    HttpRequestExecutingMessageHandler handler = new HttpRequestExecutingMessageHandler();
    handler.setExpectReply(false)
    return handler;
}

I think we need to improve docs on the matter anyway, but you can take a look into Java DSL configuration instead: https://docs.spring.io/spring-integration/docs/current/reference/html/#http-java-config. There is an Http.outboundChannelAdapter() for convenience.

Upvotes: 2

Related Questions