Spring Integration 中 AbstractMessageSource 和 MessageProducerSupport 有什么区别?
What’s the difference between AbstractMessageSource and MessageProducerSupport in Spring Integration?
在开发入站通道适配器时,我在Spring集成中找不到任何地方提到AbstractMessageSource
和MessageProducerSupport
之间的区别。我是在反应流的背景下问这个问题的,所以我实际上是在看 AbstractReactiveMessageSource
,但我想这对我的问题来说并不重要。我也想知道 MessageProducerSupport
是否支持项目反应器并且没有等同于 AbstractReactiveMessageSource
.
有一些关于这些类型的组件的文档:https://docs.spring.io/spring-integration/docs/current/reference/html/overview.html#finding-class-names-for-java-and-dsl-configuration
The inbound message flow side has its own components, which are divided into polling and listening behaviors.
因此,MessageProducerSupport
适用于那些为我们提供监听回调的协议。因此,我们可以连接到它,构建消息并将其生成到 MessageProducer
提供的通道中。因此,self-eventing 组件真正拥有监听源系统并从回调中生成消息的一切。这种类型的通道适配器称为 event-driven,它们的示例有 JMS、AMQP、HTTP、IMAP、Kinesis 等。
从这里开始,尝试将 MessageProducerSupport
与 AbstractMessageSource
进行比较是错误的,因为它们不相关。您应该查看的是 SourcePollingChannelAdapter
。正是这个就是那种类似MessageProducerSupport
的流程起点终点。唯一的问题是它是基于周期性计划任务来请求提供的 MessageSource
中的消息。这种类型的组件适用于那些不提供监听回调的协议,例如本地文件系统,(S)FTP、JDBC、MongoDb、POP3、S3 等
对于 MessageProducer
级别,您可能会期待类似于 MessageSource
的内容,但没有那种层,因为每个 event-driven 协议都有其自身的细节,因此我们无法像轮询协议那样提取一些常见的抽象。
如果您的源系统为您提供了反应式 Publisher
,则您无需查看 SourcePollingChannelAdapter
和 MessageSource
。您只需要一个 MessageProducerSupport
并从 start()
实现中调用它的 subscribeToPublisher(Publisher<? extends Message<?>> publisher)
。
在响应式实现中不需要轮询,因为 Publisher
本身不可轮询,它是 event-driven。虽然它有自己的 back-pressure 超出 MessageProducerSupport
范围的细节。
文档的这一部分也有一些解释:https://docs.spring.io/spring-integration/docs/current/reference/html/reactive-streams.html#source-polling-channel-adapter。并查看接下来的几段。
在开发入站通道适配器时,我在Spring集成中找不到任何地方提到AbstractMessageSource
和MessageProducerSupport
之间的区别。我是在反应流的背景下问这个问题的,所以我实际上是在看 AbstractReactiveMessageSource
,但我想这对我的问题来说并不重要。我也想知道 MessageProducerSupport
是否支持项目反应器并且没有等同于 AbstractReactiveMessageSource
.
有一些关于这些类型的组件的文档:https://docs.spring.io/spring-integration/docs/current/reference/html/overview.html#finding-class-names-for-java-and-dsl-configuration
The inbound message flow side has its own components, which are divided into polling and listening behaviors.
因此,MessageProducerSupport
适用于那些为我们提供监听回调的协议。因此,我们可以连接到它,构建消息并将其生成到 MessageProducer
提供的通道中。因此,self-eventing 组件真正拥有监听源系统并从回调中生成消息的一切。这种类型的通道适配器称为 event-driven,它们的示例有 JMS、AMQP、HTTP、IMAP、Kinesis 等。
从这里开始,尝试将 MessageProducerSupport
与 AbstractMessageSource
进行比较是错误的,因为它们不相关。您应该查看的是 SourcePollingChannelAdapter
。正是这个就是那种类似MessageProducerSupport
的流程起点终点。唯一的问题是它是基于周期性计划任务来请求提供的 MessageSource
中的消息。这种类型的组件适用于那些不提供监听回调的协议,例如本地文件系统,(S)FTP、JDBC、MongoDb、POP3、S3 等
对于 MessageProducer
级别,您可能会期待类似于 MessageSource
的内容,但没有那种层,因为每个 event-driven 协议都有其自身的细节,因此我们无法像轮询协议那样提取一些常见的抽象。
如果您的源系统为您提供了反应式 Publisher
,则您无需查看 SourcePollingChannelAdapter
和 MessageSource
。您只需要一个 MessageProducerSupport
并从 start()
实现中调用它的 subscribeToPublisher(Publisher<? extends Message<?>> publisher)
。
在响应式实现中不需要轮询,因为 Publisher
本身不可轮询,它是 event-driven。虽然它有自己的 back-pressure 超出 MessageProducerSupport
范围的细节。
文档的这一部分也有一些解释:https://docs.spring.io/spring-integration/docs/current/reference/html/reactive-streams.html#source-polling-channel-adapter。并查看接下来的几段。