Closed KeithMilner closed 6 years ago
@InboundChannelAdapter
is for polled endpoints; this is a message-driven endpoint.
Yes, it should be a MessageProducerSupport
; however you can configure it a little more simply, like this...
@Bean
public SmppInboundChannelAdapter smppInboundChannelAdapter(MessageChannel smsChannel) {
SmppInboundChannelAdapter smppInboundChannelAdapter = new SmppInboundChannelAdapter();
try {
smppInboundChannelAdapter.setSmppSession(smppSessionFactory().getObject());
smppInboundChannelAdapter.setChannel(smsChannel);
} catch (Exception e) {
e.printStackTrace();
}
return smppInboundChannelAdapter;
}
OK, thanks. Is there an equivalent annotation for message driven endpoints, out of interest?
No; they are simple @Bean
s; polled endpoints need two beans a SourcePollingChannelAdapter
and a MessageSource
; the annotation causes the framework to create the SPCA and a MessageSource
wrapper around the source method.
??? There is no reason for that annotation because MessageProducer
is a thing per se: https://docs.spring.io/spring-integration/reference/html/overview.html#programming-tips.
There is just no need to auto-configured some infrastructure around this type of components, like in case of pollable Channel Adapters.
OK, thanks
I'm trying to configure an SmppInboundChannelAdapter using java config, and it doesn't let me configure the channel using the InboundChannelAdapter(value="fooChannel") annotation, which I understand to be the normal way of configuring these (see JdbcPollingChannelAdapter example at https://docs.spring.io/spring-integration/reference/html/overview.html ).
I've been able to configure it using the following:
But this is rather ugly and it would be good if it could be configured using the annotation.
Looking at the adapter code, it appears to extend AbstractEndpoint and implement it's own "setChannel" method.
It would appear to be better to extend org.springframework.integration.endpoint.MessageProducerSupport instead, which provides methods for setOutputChannel, setOutputChannelName, etc. which appear to be what is expected by the annotation.