如何在publishSubscribe()中指定taskExecutor

时间:2016-07-09 00:10:45

标签: spring spring-integration

如何"翻译"以下XML配置为等效的Spring集成java-dsl?

<int:publish-subscribe-channel id="channel" task-executor="myex">
</int:publish-subscribe-channel>

<task:executor id="myex" pool-size="10"></task:executor>

我已阅读DSL Reference Guide,但仍无法弄明白。

1 个答案:

答案 0 :(得分:2)

MessageChannels章指出MessageChannels工厂。因此,<publish-subscribe-channel> XML配置转换为Java配置,如:

@Bean
public MessageChannel channel() {
    return MessageChannels.publishSubscribe(myExecutor()).get();
}

虽然您可以使用原始Java配置达到相同的目的:

@Bean
public MessageChannel channel() {
    return new PublishSubscribeChannel(myExecutor());
}