2016-12-27 48 views
0

我創建了一個控制通道和一個網關服務來向該通道發送控制消息。但是,在我調用網關服務方法後,應該返回布爾值在消息提交後不返回。Spring集成網關服務方法在啓動/停止時不返回

代碼段:

public interface SampleControlService { 
    boolean sendControl(String message); 
} 

.... 

@Autowired 
private SampleControlService sampleControlService; 

..... 

boolean done = sampleControlService.sendControl("@testAdapter.stop()"); // message gets sent but it is not returning to caller 

System.out.println("Done : " + done); // this line doesn't execute 


// integration config 
<int:channel id="controlChannel"/> 
<int:gateway service-interface="com.test.service.SampleControlService" default-request-channel="controlChannel" /> 
<int:control-bus input-channel="controlChannel"/> 

但是,如果我發送消息@ testAdapter.isRunning()來檢查狀態,它會返回預期。

回答

1

那麼void stop()不會返回結果,而boolean isRunning()確實;網關不知道被調用的方法;你正在「告訴」你期待的結果永遠不會到來。

您可以添加其他網關方法

void sendOneWayControl(String command); 

或添加default-reply-timeout="0"到網關,你會得到一個null回報。

+0

謝謝,增加了新的方法。 – zdesam