通道适配器和消息网关模式有什么区别?
无论我读了多少关于这两种模式的文章,我都看不出其中的区别。
No matter how much I read about those two patterns I just can't see the difference.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
无论我读了多少关于这两种模式的文章,我都看不出其中的区别。
No matter how much I read about those two patterns I just can't see the difference.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
这是一个很好的问题,因为它们的相似之处在于它们都提供对消息系统的应用程序访问。我认为正是他们实现这一目标的方式使他们与众不同。
通道适配器模式涉及如何从现有系统获取数据而不修改该系统。通常,通道适配器是在进程外实现的。常见的示例是定期遍历底层数据库以查找要排队的内容的程序。也许是一个独立的应用程序,它调用远程处理或 HTTP API 来访问系统数据以创建消息。重点是,非消息系统完全未经修改。
我认为消息网关更适合进程内消息传递集成。它实际上是关于在消息子系统周围应用良好的面向对象封装。也许系统中的某个对象称为 WorkOrderSender,其方法称为 Send(WorkOrder wo)。该类的实现使应用程序免受消息传递的任何细节的影响......对该类的调用只是另一个方法调用。事实上,应该可以更换您的消息传递供应商,甚至将消息传递换成 HTTP 或 FTP 等。
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.
来自 Spring 集成参考文档:
虽然 JMS 通道适配器旨在用于单向消息传递(仅发送或仅接收),但 Spring Integration 还为请求/回复操作提供入站和出站 JMS 网关。
请参阅http://static.springsource.org/spring-integration/reference/htmlsingle /#jms
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
来自 文档:
From the documentation: