通道适配器和消息网关模式有什么区别?

发布于 2024-12-14 19:59:38 字数 36 浏览 1 评论 0原文

无论我读了多少关于这两种模式的文章,我都看不出其中的区别。

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夜唯美灬不弃 2024-12-21 19:59:38

这是一个很好的问题,因为它们的相似之处在于它们都提供对消息系统的应用程序访问。我认为正是他们实现这一目标的方式使他们与众不同。

通道适配器模式涉及如何从现有系统获取数据而不修改该系统。通常,通道适配器是在进程外实现的。常见的示例是定期遍历底层数据库以查找要排队的内容的程序。也许是一个独立的应用程序,它调用远程处理或 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.

送君千里 2024-12-21 19:59:38

来自 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

夜巴黎 2024-12-21 19:59:38

来自 文档

  • 入站通道适配器用于单向集成,将数据引入消息传递应用程序。
  • 出站通道适配器用于单向集成,以将数据发送到消息传递应用程序之外。
  • 入站网关用于双向集成流,其中某些其他系统调用消息传递应用程序并接收回复。
  • 出站网关用于双向集成流,其中消息传递应用程序调用某些外部服务或实体并期望结果。

From the documentation:

  • Inbound channel adapters are used for one-way integration to bring data into the messaging application.
  • Outbound channel adapters are used for one-way integration to send data out of the messaging application.
  • 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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文