简体   繁体   English

Spring集成 - 入站和出站通道适配器

[英]Spring Integration - Inbound vs Outbound Channel Adapters

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. 我已经回顾了Spring文档,这种“定向”区别对我来说并不清楚。 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! 谢谢!

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: 有两种类型的入站通道适配器:

  • MessageProducer s MessageProducer s
  • MessageSource s MessageSource

MessageProducer s are termed "message-driven" ie they unilaterally produce messages in a completely asynchronous manner, as soon as they are started; MessageProducer被称为“消息驱动”,即它们一旦启动就以单一方式以完全异步的方式生成消息; examples are JMS message-driven adapter, TCP inbound channel adapter, IMAP Idle (mail) channel adapter, etc. 示例是JMS消息驱动适配器,TCP入站通道适配器,IMAP空闲(邮件)通道适配器等。

MessageSource s on the other hand are polled - a poller with some trigger causes the framework to ask the source for a message; 另一方面, MessageSource被轮询 - 具有一些触发器的poller导致框架向源询问消息; the trigger can be on a fixed rate, cron expression etc. Examples are the (S)FTP adapters, Mail inbound adapter (POP3. IMAP). 触发器可以是固定速率,cron表达式等。例如(S)FTP适配器,邮件入站适配器(POP3.IMAP)。

Examples of outbound adapters are Mail outbound adapter (SMTP). 出站适配器的示例是邮件出站适配器(SMTP)。

Gateways are two-way (request/reply). 网关是双向的(请求/回复)。

Inbound gateways are where some external system sends a request and Spring Integration replies. 入站网关是一些外部系统发送请求和Spring Integration回复的地方。

Outbound gateways are where Spring Integration makes the request and some external system replies. 出站网关是Spring Integration发出请求的地方,也是一些外部系统回复。

I hope that clears things up. 我希望能够解决问题。

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. 在Spring集成中,基础是Spring集成框架(可以看作是消息总线),适配器将消息放入其中,适配器从中取出消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM