【问题标题】:Spring Integration Gateway Service method not returning upon start/stopSpring Integration Gateway Service 方法在启动/停止时不返回
【发布时间】:2016-12-27 08:22:25
【问题描述】:

我创建了一个控制通道和一个网关服务来向该通道发送控制消息。但是,在我调用应该返回布尔值的网关服务方法后,在消息提交后没有返回。

代码片段:

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() 来检查状态,它会按预期返回。

【问题讨论】:

    标签: java spring-integration gateway


    【解决方案1】:

    void stop() 不会返回结果,而 boolean isRunning() 会;网关对被调用的方法一无所知;你正在“告诉”框架你期待一个永远不会出现的结果。

    您可以添加其他网关方法

    void sendOneWayControl(String command);
    

    或将default-reply-timeout="0" 添加到网关,您将获得null 返回。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-16
      • 2017-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-12
      • 2018-10-11
      相关资源
      最近更新 更多