Inbound Messaging Gateways
SimpleMessagingGateway
Even though the MessageChannelTemplate is fairly straightforward, it does not hide the
details of messaging from your application code. To support working with plain Objects instead of messages,
Spring Integration provides SimpleMessagingGateway with the following methods:
sendAndReceiveMessage(Object object);]]>
It enables configuration of a request and/or reply channel and delegates to instances of the
InboundMessageMapper and OutboundMessageMapper
strategy interfaces.
SimpleMessagingGateway gateway = new SimpleMessagingGateway(inboundMapper, outboundMapper);
gateway.setRequestChannel(requestChannel);
gateway.setReplyChannel(replyChannel);
Object result = gateway.sendAndReceive("test");
GatewayProxyFactoryBean
Working with Objects instead of Messages is an improvement. However, it would be even better to have no
dependency on the Spring Integration API at all - including the gateway class. For that reason, Spring
Integration also provides a GatewayProxyFactoryBean that generates a proxy for
any interface and internally invokes the gateway methods shown above. Namespace support is also
provided as demonstrated by the following example.
]]>
Then, the "fooService" can be injected into other beans, and the code that invokes the methods on that
proxied instance of the FooService interface has no awareness of the Spring Integration API. The general
approach is similar to that of Spring Remoting (RMI, HttpInvoker, etc.). See the "Samples" Appendix for
an example that uses this "gateway" element.
The reason that the attributes on the 'gateway' element are named 'default-request-channel' and
'default-reply-channel' is that you may also provide per-method channel references by using the
@Gateway annotation.