java - Spring Integration Gateway 服务方法在启动/停止时不返回

标签 java spring-integration gateway

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

代码片段:

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

最佳答案

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

您可以添加其他网关方法

void sendOneWayControl(String command);

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

关于java - Spring Integration Gateway 服务方法在启动/停止时不返回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41341515/

相关文章:

java - 每次在 Java 中调用方法时,都会从 CSV 文件中读取新行

spring-integration - 如何在文件内容上使用 Spring Integration 转换器,然后将文件存档

api - Omnipay 添加新网关

java - Spring Integration - Java 配置 - 事务感知流程

Spring集成JPA网关: act on empty result

java - 任何支付网关的购物车 API? (至少需要支付宝)

design-patterns - 外观设计模式和网关设计模式有什么区别?

java - 有什么办法可以让Cloud Dataflow像流一样输出吗?

java - Camel RabbitMQ 消费者 : what's the interaction between concurrentConsumers and threadPoolSize options?

java - 镜像 JLabel 或 JTextArea