What is the difference between a channel adapter and a messaging gateway pattern?

14,768

Solution 1

That's a great question since they are similar in that they provide an application access to a messaging system. It is how they acheive it I think that differentiates them.

The Channel Adapter pattern deals how to get data from an existing system without modifying that system. Typically the Channel Adapdter is implemented out-of-process. Examples often seen are a program that periodically walks an underlying database to find things to enqueue. Of perhaps a stand-alone app that calls a remoting or HTTP API to access a systems data to create messages. The point being, that the non-messaging system is completely unmodified.

I think Message Gateway is more intended for in-process messaging integration. It is really about applying good OO encapsulation around the message subsystem. Perhaps some object in the system is called WorkOrderSender with a method called Send(WorkOrder wo). The implementation of that class shields the application from any details of messaging...to it the call is just another method call. In fact, it should be possible to swap out your messaging vendor or even trade messaging for HTTP or FTP etc.

Solution 2

In Spring Integration, the pattern name Channel Adapter applies to any unidirectional inbound or outbound adapter. In other words, an inbound channel adapter supports an in-only message exchange, and an outbound channel adapter supports an out-only exchange.

Any bidirectional, or request-reply, adapter is known as a Gateway in Spring Integration

CHANNEL ADAPTER

A Channel Adapter connects an application to the messaging system In Spring Integration we chose to constrict the definition to include only connections that are unidirectional, so a unidirectional message flow begins and ends in a channel adapter. Many different kinds of channel adapters exist, ranging from a method-invoking channel adapter to a web service channel adapter

a channel adapter is placed at the beginning and the end of a unidirectional message flow.

enter image description here MESSAGING GATEWAY

In Spring Integration, a Messaging Gateway is a connection that’s specific to bidirectional messaging. If an incoming request needs to be serviced by multiple threads but the invoker needs to remain unaware of the messaging system, an inbound gateway provides the solution. On the outbound side, an incoming message can be used in a synchronous invocation, and the result is sent on the reply channel.

For example, outbound gateways can be used for invoking web services and for synchronous request-reply interactions over JMS.

enter image description here

A gateway can also be used midstream in a unidirectional message flow. As with the channel adapter, we’ve constrained the definition of messaging gateway a bit in comparison to Enterprise Integration Patterns.

enter image description here

reference: Spring Integration in Action

Solution 3

From Spring integration reference docs:

Whereas the JMS Channel Adapters are intended for unidirectional Messaging (send-only or receive-only), Spring Integration also provides inbound and outbound JMS Gateways for request/reply operations.

See http://static.springsource.org/spring-integration/reference/htmlsingle/#jms

Share:
14,768

Related videos on Youtube

Pillblast
Author by

Pillblast

Updated on June 03, 2022

Comments

  • Pillblast
    Pillblast about 2 years

    No matter how much I read about those two patterns I just can't see the difference.

  • BitMask777
    BitMask777 over 11 years
    If @Pillblast is referring to the patterns as described in the Enterprise Integration Patterns book by Hohpe and Woolf, then I agree. Other definitions may vary (see the Spring reference by emush below). In cases where I have implemented these patterns I have actually used the Messaging Gateway within a Channel Adapter to abstract the underlying messaging system the same way I do within an application.