SI 发布-订阅通道 - 并行执行还是顺序执行?
SI Publish-subscribe channel - parallel or sequential execution?
我创建了一个发布-订阅频道,比如
@Bean
MessageChannel parallelRunningSubscribableChannel() {
return MessageChannels.publishSubscribe("parallelRunningSubscribableChannel").get();
}
我的主要流程以该频道结束,另外 2 个流程以该频道开始:
@Bean
public IntegrationFlow mainFlow() {
return IntegrationFlows
.from(...)
...
.channel(parallelRunningSubscribableChannel)
.get();
}
@Bean
public IntegrationFlow subFlow1() {
return flow -> flow.channel(parallelRunningSubscribableChannel())
.handle(...)
...
}
@Bean
public IntegrationFlow subFlow2() {
return flow -> flow.channel(parallelRunningSubscribableChannel())
.handle(...)
...
}
我假设 subFlow1 和 subFlow2 运行 是顺序的(例如,首先是 subFlow1 运行s,然后是 subflow2),对吗?
我需要知道是否创建了一个新线程,因为我想要同一数据库事务中的 2 个子流 运行。
出于好奇,我怎样才能使 2 个子流程 运行 并行?
谢谢!
此致,
五、
PublishSubscribeChannel
默认不并发。请参阅文档:https://docs.spring.io/spring-integration/docs/current/reference/html/core.html#channel-implementations-publishsubscribechannel
要让这些订阅者在他们自己的线程中并行工作,您需要明确地为此频道配置 TaskExecutor
。
I'd want to the 2 subflows run in the same db transaction.
如果让它们并行,它们将在自己的线程中工作,因此它们不能参与同一个 TX。
我创建了一个发布-订阅频道,比如
@Bean
MessageChannel parallelRunningSubscribableChannel() {
return MessageChannels.publishSubscribe("parallelRunningSubscribableChannel").get();
}
我的主要流程以该频道结束,另外 2 个流程以该频道开始:
@Bean
public IntegrationFlow mainFlow() {
return IntegrationFlows
.from(...)
...
.channel(parallelRunningSubscribableChannel)
.get();
}
@Bean
public IntegrationFlow subFlow1() {
return flow -> flow.channel(parallelRunningSubscribableChannel())
.handle(...)
...
}
@Bean
public IntegrationFlow subFlow2() {
return flow -> flow.channel(parallelRunningSubscribableChannel())
.handle(...)
...
}
我假设 subFlow1 和 subFlow2 运行 是顺序的(例如,首先是 subFlow1 运行s,然后是 subflow2),对吗?
我需要知道是否创建了一个新线程,因为我想要同一数据库事务中的 2 个子流 运行。
出于好奇,我怎样才能使 2 个子流程 运行 并行?
谢谢!
此致,
五、
PublishSubscribeChannel
默认不并发。请参阅文档:https://docs.spring.io/spring-integration/docs/current/reference/html/core.html#channel-implementations-publishsubscribechannel
要让这些订阅者在他们自己的线程中并行工作,您需要明确地为此频道配置 TaskExecutor
。
I'd want to the 2 subflows run in the same db transaction.
如果让它们并行,它们将在自己的线程中工作,因此它们不能参与同一个 TX。