java - 如何在 JmsMessagingTemplate.sendAndReceive 上设置等待超时

标签 java spring spring-mvc spring-jms spring-messaging

我在 MVC Controller 中使用来自 JmsMessagingTemplate 的 sendAndReceive,但如果没有发送回复消息,它似乎会永远等待回复。文档指出:

Returns: the reply, possibly null if the message could not be received, for example due to a timeout

但是我无法弄清楚超时时间是多少,也不知道在哪里配置。谁能给我解释一下?

仅供引用:我没有使用 spring-integration,而是 spring-messaging。

最佳答案

你可以通过JmsTemplate在创建 JmsMessagingTemplate

JmsTemplate 中你可以配置 property setReceiveTimeout(long receiveTimeout) 其中时间以毫秒为单位

关于java - 如何在 JmsMessagingTemplate.sendAndReceive 上设置等待超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33375681/

相关文章:

java - Spinner 值自动更新到位置 0,该位置从 firebase 获取数据

Java - 最大堆中整数的非字典序倒序

java - 为什么我没有找到适合 jdbc 的驱动程序 :derby://localhost:1527/employee;create=true error in my code?

java - 为什么使用 Spring Mail 会丢失附件? ( Kotlin )

java - 使用WebFlux时如何使用HTTP DELETE发送正文?

java - spring mvc @Autowired错误不满足 'required'类型依赖

java - 使用 Spring Boot 初始化 hibernate、jpa 和 MysqlApp?

java - Spring + Hibernate 延迟加载错误

hibernate - Spring @RequestBody 不查找对象

java - 有 header 时请求映射不起作用