如何在 JmsMessagingTemplate.sendAndReceive 上设置等待超时 [英] How to set waiting timeout on JmsMessagingTemplate.sendAndReceive
问题描述
我在 MVC 控制器中使用来自 JmsMessagingTemplate 的 sendAndReceive 但如果没有发送回复消息,它似乎一直在等待回复.文档指出:
I'm using sendAndReceive from JmsMessagingTemplate in an MVC controller but if no reply message is sent it seems to keep waiting on a reply forever. The documentation states that:
返回:回复,如果无法接收消息,则可能为 null,例如由于超时
Returns: the reply, possibly null if the message could not be received, for example due to a timeout
但是,我不知道给出超时多长时间或在哪里配置它.有人可以向我解释一下吗?
However I just can't figure out after how long a timeout is given or where to configure this. Can someone explain this to me?
仅供参考:我使用的不是 spring-integration,而是 spring-messaging.
推荐答案
你可以通过 JmsTemplate 同时创建 JmsMessagingTemplate
You can pass JmsTemplate while creating JmsMessagingTemplate
在JmsTemplate
中,您可以配置property setReceiveTimeout(long receiveTimeout)
其中时间以毫秒为单位
in JmsTemplate
you can configure property setReceiveTimeout(long receiveTimeout)
where time is in milliseconds
这篇关于如何在 JmsMessagingTemplate.sendAndReceive 上设置等待超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!