小编sj0*_*509的帖子

在 Spring Integration 中的发布-订阅通道上指定 ServiceActivator 的顺序(使用 javaConfig)

我当前正在integration-context.xml 文件中指定服务激活器和相关的发布-订阅通道。像这样(精简版):

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

<int:gateway service-interface="com.integration.gateway.RestClientGateway" default-request-channel="notificationChannel" async-executor="executor"/>

<int:service-activator ref="restClient" method="sendRequest" **order="1"** input-channel="notificationChannel"/>
<int:service-activator ref="actionPersistor" method="persistNotification" **order="2"** input-channel="notificationChannel"/>
Run Code Online (Sandbox Code Playgroud)

现在我需要指定一个自定义执行器类(用于 MDC 日志记录),因此我开始尝试将其转移到基于注释的方法。类似这样的事情:

@Bean
@Description("PubSub channel for notification")
public MessageChannel notificationChannel() {
    return new PublishSubscribeChannel(mdcTaskExecutor());
}

@Bean
public TaskExecutor mdcTaskExecutor() {
    return MDCThreadPoolTaskExecutor.newWithInheritedMdc(10, 20, 25);
}

@MessagingGateway(name = "restClientGateway", defaultRequestChannel = "notificationChannel", asyncExecutor = "mdcExecutor")
public interface RestClientGateway {

    Future<Message<String>> sendRequest(Message<BlEvent> message);
}

@ServiceActivator(inputChannel = "notificationChannel")
public Message<String> sendRequest(Message<BlEvent> message) {

@ServiceActivator(inputChannel="notificationChannel")
public void persistNotification(Message<BlEvent> message) {
Run Code Online (Sandbox Code Playgroud)

我的问题是,是否有任何方法可以指定 @ServiceActivators 从 …

spring annotations spring-integration

5
推荐指数
1
解决办法
1082
查看次数

标签 统计

annotations ×1

spring ×1

spring-integration ×1