[英]Publisher should wait till broker is available
I have a simple publisher, which sends messages to a queue. 我有一个简单的发布者,它将消息发送到队列。
<int:channel id="publishChannel"/>
<int-jms:outbound-channel-adapter channel="publishChannel" destination="testQueue" session-transacted="true"/>
@Publisher(channel = "publishChannel")
public String sendMessage (String text) {
return text;
}
If the broker crashes, the publisher throws an MessageHandlingException. 如果代理崩溃,则发布者将抛出MessageHandlingException。
Is it possible to block the publisher, till the broker is available again or to make a periodic retry? 是否可以阻止发布者,直到代理再次可用或进行定期重试?
You can add a retry advice to the outbound adapter . 您可以向出站适配器添加重试建议 。
<int-jms:outbound-channel-adapter channel="publishChannel" destination="testQueue" session-transacted="true>
<int:request-handler-advice-chain>
<ref bean="myRetryAdvice" />
</request-handler-advice-chain>
</int-jms:outbound-channel-adapter>
You can configure the advice with a backoff policy (eg exponential) and to take some action when retries are exhausted (rather than throwing the final exception). 您可以使用退避策略(例如指数)配置建议,并在重试用尽时采取一些措施(而不是抛出最终异常)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.