简体   繁体   English

Spring 集成:以列表形式获取频道中的消息

[英]Spring integration : Get messages in channel as List

I want to subscribe to a PubSub channel, to get all messages payload and processing them.我想订阅一个 PubSub 频道,以获取所有消息有效负载并进行处理。

The thing is, I saw example with IntegrationFlow , but if I understand this correctly, integrationFlow is used to get from a channel, and send to another one.问题是,我看到了IntegrationFlow的示例,但如果我理解正确,integrationFlow 用于从一个通道获取,然后发送到另一个通道。

I don't want to send to another channel, I just want to get the payload, to process it.我不想发送到另一个频道,我只想获取有效负载,进行处理。

How can I do this?我怎样才能做到这一点?

All examples I found use xml files to make the configuration, but the project was not created using this way of doing.我发现的所有示例都使用 xml 文件进行配置,但项目不是使用这种方式创建的。

I saw example with IntegrationFlow, but if I understand this correctly, integrationFlow is used to get from a channel, and send to another one.我看到了 IntegrationFlow 的示例,但如果我理解正确的话,integrationFlow 用于从一个通道获取并发送到另一个通道。

I think that this is not correct information.我认为这不是正确的信息。 You can just handle the messages.你可以只处理消息。 You can do something like this in a configuration class:您可以在配置 class 中执行以下操作:

@Bean
public IntegrationFlow myFlow() {
  return IntegrationFlows.from(...)
    .handle((GenericHandler<YourMessage>) (message, headers) -> {...})
}

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

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