2016-11-08 149 views
1

我正在使用Spring Integration DSL加快速度。我正在玩下面的例子。Spring集成Java DSL - IntegrationFlow多個用戶

@Bean 
    public IntegrationFlow flow() { 
     return IntegrationFlows.from(INBOX) 
       .transform(p -> "world") 
       .get(); 
    } 

我在尋找從這一個流程訂閱多個渠道的能力。我找不到任何關於此的信息。

例如類似於下面的內容,其中此流程訂閱了不同的渠道。

@Bean 
     public IntegrationFlow flow() { 
      return IntegrationFlows.from(INBOX).flow(INBOX2) 
        .transform(p -> "world") 
        .get(); 
     } 

回答

3

這是不可能的。沒有任何Endpoint與幾個inputChannel s。

在另一方面,我們不需要這樣的複雜性,因爲我們總能bridge從一個通道到另一個:

@Bean 
@BridgeTo(INBOX) 
public MessageChannel INBOX2() { 
    return new DirectChannel(); 
} 

你也可以考慮使用一些router始終計算所需通道輸出。

MessageChannel在Spring集成設計中本身很複雜,因此混淆端點邏輯聽起來不太合適。

1

在本教程中[Receive and send multiple JMS messages in one transaction with Spring Integration Java DSL],他們描述的那樣

但是這個屬性尚不可用的Java DSL。解決此問題的另一種方法是用事務性輪詢器替換消息驅動的 通道適配器,但這在目前的Java DSL中也可能不是 。爲了解決這個問題,我們使用jmsTemplate替換了出站適配器中的 jmsFactory,並將會話 事務處理設置爲true。導致:

IntegrationFlows 
    .from(subscribableChannel()) 
    .handle(Jms.outboundAdapter(jmsTemplate).destination(QUEUE2)) 
.get(); 
相關問題