简体   繁体   English

发布者应等待经纪人可用

[英]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.

相关问题 如何等待@Scheduled 直到上一个任务未完成? - How wait @Scheduled till previous task is not finished? Spring Integration - 等到完成处理文件 - Spring Integration - Wait till finishes processing file Spring 云 Stream Binder Kafka 代理不可用 - Spring Cloud Stream Binder Kafka broker is not available Spring-Boot和Kafka:如何处理不可用的经纪人? - Spring-Boot and Kafka : How to handle broker not available? 如何在 Spring Kafka Listener 中捕获警告“代理可能不可用” - How to catch warning "Broker may not be available" at the Spring Kafka Listener Kafka + Spring 本地代理可能不可用。 Windows 10 - Kafka + Spring locally broker may not be available. Windows 10 在Spring Boot中,我有一个异步调用,我必须等待下一个线程等待直到CRUD操作 - In Spring Boot i have a Async call and I have to wait my next thread to wait till CRUD Operation “消息:经纪人不可用。” 在 spring websocket 上执行 stomp 时出错 - "message:Broker not available." error when implementing stomp over spring websocket Spring Boot Kafka 启动错误“无法建立到节点 -1 的连接。代理可能不可用。” - Spring Boot Kafka Startup error "Connection to node -1 could not be established. Broker may not be available." Spring JMS ActiveMQ使用什么来确定代理何时应切换“排他消费者”? - What does Spring JMS ActiveMQ use to determine when a broker should switch Exclusive Consumers?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM