问题描述
我工作在ActiveMQ中一个系统,我真的preFER不丢失消息的。我的问题是重试的消息引起我的消费者块(而不是在他们可以处理消息的工作)。我想给失败的消息几天来重试(例如,我的潜力的旅游目的地之一是另一台服务器,我会通过SFTP访问,这可能是关闭),但我不希望消费者堵了好几天 - - 我希望它保持对其他消息的工作。
I'm working on a system in ActiveMQ where I would really prefer not to lose messages. My problem is that retrying messages is causing my consumers to block (instead of working on messages they could handle). I'd like to give failed messages several days to retry (for example, one of my potential destinations is another server I'll access via SFTP, which could be down), but I don't want a consumer blocking for several days -- I want it to keep working on the other messages.
有没有办法告诉经纪人后来重新发送邮件?现在我正在研究采取消息从队列,并把它与一个延迟,但我想知道如果有一个简单的方法。我使用Apache的骆驼,因此使用该解决方案将是一件好事。
Is there a way to tell the broker to resend the message later? Right now I'm looking into taking the message off of the queue and putting it on with a delay, but I'm wondering if there's a simpler way. I'm using Apache Camel, so a solution using that would be good too.
推荐答案
骆驼可以用这肯定有助于...
Camel can definitely help with this...
的一种方法是使用单独的队列中,并周期性地从主流动(特别是当性能是一个问题)分别重试的消息。此外,这提供了一个单独的队列,让您可以分流这些错误消息(查看,清楚,涂改,手动重试等)...
One way is to use a separate queue and periodically retry messages separately from the main flow (especially when performance is a concern). Also, this provides a separate queue to allow you to triage those error messages (view, clear, alter, manually retry, etc)...
这样的事情...详情请参阅
something like this...see polling consumer for more details
//main route to process message from a queue (needs to be fast)
from("activemq:queue:mainQ").process(...);
//handle any errors by simply moving them to an error queue (for retry later)
onException(Exception.class)
.handled(true).to("activemq:queue:mainErrorQ");
//retry the error queue
from("timer://retryTimer?fixedRate=true&period=60000")
.bean(myBean, "retryErrors");
...
public void retryErrors() {
// loop to empty queue
while (true) {
// receive the message from the queue, wait at most 3 sec
Exchange msg = consumer.receive("activemq:queue.mainErrorQ", 3000);
if (msg == null) {
// no more messages in queue
break;
}
// send it to the starting queue
producer.send("activemq:queue.mainQ", msg);
}
}
如果你的土地上更好的解决办法,让我知道...好运气
If you land on a better solution, let me know...good luck
这篇关于在未来的某个时候重试的消息(ActiveMQ的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!