Spring integration Spring集成持久消息存储
我如何告诉spring integration在流中持久化消息,并在应用程序关闭时进行恢复 我有如下spring集成流程:Spring integration Spring集成持久消息存储,spring-integration,spring-integration-dsl,Spring Integration,Spring Integration Dsl,我如何告诉spring integration在流中持久化消息,并在应用程序关闭时进行恢复 我有如下spring集成流程: IntegrationFlows .from(ftpInboundAdapter) { c -> c.poller(Pollers.fixedRate(1000).maxMessagesPerPoll(1)) } .transform<File, JobLaunchRequest> { toAJobReque
IntegrationFlows
.from(ftpInboundAdapter) { c -> c.poller(Pollers.fixedRate(1000).maxMessagesPerPoll(1)) }
.transform<File, JobLaunchRequest> { toAJobRequest(it, aJob) }
.handle(JobLaunchingGateway(jobLauncher))
.transform<JobExecution, JobLaunchRequest> { toBJobRequest(bJob) }
.handle(JobLaunchingGateway(jobLauncher))
.handle { _ -> }
.get()
.channel { c -> c.queue(jdbcChannelMessageStore, "persistentGroup") }
没有成功。您关于JDBC
MessageStore
的想法是正确的,问题是您没有展示如何使用该jdbcChannelMessageStore
bean
根据您的需要,您需要使用此MessageStore
注入QueueChannel
,但您的流程完全没有任何通道自定义
要在流中创建一个持久通道,您需要有如下内容:
IntegrationFlows
.from(ftpInboundAdapter) { c -> c.poller(Pollers.fixedRate(1000).maxMessagesPerPoll(1)) }
.transform<File, JobLaunchRequest> { toAJobRequest(it, aJob) }
.handle(JobLaunchingGateway(jobLauncher))
.transform<JobExecution, JobLaunchRequest> { toBJobRequest(bJob) }
.handle(JobLaunchingGateway(jobLauncher))
.handle { _ -> }
.get()
.channel { c -> c.queue(jdbcChannelMessageStore, "persistentGroup") }
(您需要以某种方式在流中注入jdbcChannelMessageStore
bean)
这样,消息将存储在基于INT\u CHANNEL\u MESSAGE
表的数据中。他们会在那边的坠机事故中幸存下来
您还需要记住,QueueChannel
是不可订阅的,必须对其进行轮询。因此,流中此通道定义之后的端点必须使用轮询器进行配置。例如:
.channel { c -> c.queue(jdbcChannelMessageStore, "persistentGroup") }
.handle(JobLaunchingGateway(jobLauncher), e -> e.poller(p -> p.fixedDelay(1000)))
所有答案都出现在文档中:
顺便说一句,我们有一个专门的项目来简化Kotlin的体验:我没有展示如何使用jdbcChannelMessageStore的原因是我没有使用它——这就是问题所在。我认为,如果我像这样显式地定义存储,它将被注入到某个地方,持久通道将被用作默认通道。我现在明白这是胡说八道。