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

前端 未结 3 1091
长情又很酷
长情又很酷 2021-01-30 17:07

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

相关标签:
3条回答
  • 2021-01-30 17:11

    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

    0 讨论(0)
  • 2021-01-30 17:14

    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.

    0 讨论(0)
  • 2021-01-30 17:23

    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.

    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.

    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.

    reference: Spring Integration in Action

    0 讨论(0)
提交回复
热议问题