簡體   English   中英

在Spring Integration中的發布 - 訂閱通道上指定ServiceActivator的順序(使用javaConfig)

[英]Specifying order of ServiceActivator on a publish-subscribe channel in Spring Integration (using 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"/>

現在我需要指定一個自定義執行器類(用於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) {

我的問題是,如果有任何方法可以指定@ServiceActivators從pub-sub通道接收消息的順序,類似於我在integration-context.xml中定義消息的方式。

非常感謝你的幫助。 如果這樣設置屬性太簡單了,請提前道歉,因為我似乎無法找到它。

是的,你可以簡單地將@Order與那些Messaging注釋一起添加。

我想我們在參考手冊中有一個遺漏,沒有提到。

隨意就此事提出JIRA票!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM