Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Integration - Inbound vs Outbound Channel Adapters

Tags:

What is the fundamental difference between inbound and outbound channel adapters?

Any examples would be very helpful.

I have reviewed the Spring docs and this "directional" distinction is not clear to me. I support an application that has an outbound-channel-adapter configured, but I find the behavior counter intuitive with the outbound label. This adapter gets an external file, then brings it in to the application where we parse the file and persist the data.

This is similar to this question, but I wanted to focus more generally on channel adapters, and hopefully get more feedback!

Thanks!

like image 943
The Gilbert Arenas Dagger Avatar asked May 01 '15 15:05

The Gilbert Arenas Dagger


People also ask

What is inbound and outbound in Spring Integration?

Inbound gateways are used for a bidirectional integration flow, where some other system invokes the messaging application and receives a reply. Outbound Gateways are used for a bidirectional integration flow, where the messaging application invokes some external service or entity and expects a result.

What is inbound channel adapter in spring?

An "inbound-channel-adapter" element can invoke any method on a Spring-managed Object and send a non-null return value to a MessageChannel after converting it to a Message . When the adapter's subscription is activated, a poller will attempt to receive messages from the source.

What are the types of adapters in Spring Integration?

There are both inbound and outbound adapters, and each may be configured with XML elements provided in the core namespace. These provide an easy way to extend Spring Integration, as long as you have a method that can be invoked as either a source or a destination.

What is outbound gateway in Spring Integration?

The outbound Gateway creates JMS Messages from Spring Integration Messages and then sends to a 'request-destination'.


2 Answers

Channel adapters are for one-way integration (gateways are bidirectional).

Concretely, inbound adapters are at the beginning of a flow, outbound adapters terminate a flow. Flows are typically rendered (and conceptually thought of as flowing from left to right)...

inbound-c-a->someComponent->someOtherComponent->outbound-ca

(where -> represents a channel).

There are two types of inbound channel adapters:

  • MessageProducers
  • MessageSources

MessageProducers are termed "message-driven" i.e. they unilaterally produce messages in a completely asynchronous manner, as soon as they are started; examples are JMS message-driven adapter, TCP inbound channel adapter, IMAP Idle (mail) channel adapter, etc.

MessageSources on the other hand are polled - a poller with some trigger causes the framework to ask the source for a message; the trigger can be on a fixed rate, cron expression etc. Examples are the (S)FTP adapters, Mail inbound adapter (POP3. IMAP).

Examples of outbound adapters are Mail outbound adapter (SMTP).

Gateways are two-way (request/reply).

Inbound gateways are where some external system sends a request and Spring Integration replies.

Outbound gateways are where Spring Integration makes the request and some external system replies.

I hope that clears things up.

like image 68
Gary Russell Avatar answered Oct 02 '22 17:10

Gary Russell


in and out are relative directions, it must have a base. in spring integration, the base is the Spring integration framework ( that can be looked as a message bus), the adapters put message into it are in, the adapters take message out from it are out.

like image 37
Andrew Avatar answered Oct 02 '22 16:10

Andrew