0
votes

I have a question on spring integration gateways. As I read from documentation http://docs.spring.io/spring-integration/reference/htmlsingle/#gateway we have a general purpose gateway.

So, I am failing to understand the reasons to build any specific outbound or inbound gateways for new integrations. Are there any specific reasons to go with developing custom gateways?

Thanks in advance Regards Kalyan

1

1 Answers

1
votes

The @MessagingGateway (<gateway>) represents a POJI adapter to the Messaging subsystem, where your original code doesn't care about internals and just deals with target domain. That's a type of in-application integration.

When you need to interact with external world (or some specific internal protocol, e.g. Spring Application Events), you still need to adapt it somehow to your Messaging subsystem. For this purpose we have inbound gateways/adapters to receive data/events/packages/messages from the external system/protocol and outbound gateways/adapters to transform messages to protocol-specific entities and send there.

The gateway is two-way request/reply abstraction. The adapter only one-way: only to receive or only to send.

You can find some Gateway explanation in the EIP Book.

Most popular protocols are covered in Spring Integration, e.g. HTTP, AMQP, JMS, WebSockets, JDBC, Mail etc.

You need custom gateway (inbound or outbound), if there is a desired protocol adapters implementation in Spring Integration.

But, yeah, don't mix @MessagingGateway on simple interface with the HttpRequestHandlingMessagingGateway (inbound) or SftpMessageHandler (outbound) gateways, for example.