在将来的某个时间重试消息(ActiveMQ)

|| 我正在ActiveMQ上的一个系统上工作,我真的希望不会丢失消息。我的问题是,重试消息导致我的使用者阻塞(而不是处理他们可以处理的消息)。我想为失败的消息提供几天以重试(例如,我的潜在目标之一是我将通过SFTP访问的另一台服务器,该服务器可能已关闭),但我不想让使用者阻止几天-我希望它继续处理其他消息。 有没有办法告诉经纪人以后重新发送消息?现在,我正在考虑将消息从队列中移出并延迟放置,但是我想知道是否有更简单的方法。我正在使用Apache Camel,因此使用该解决方案也是不错的选择。     
已邀请:
骆驼绝对可以帮上忙... 一种方法是使用单独的队列,并与主流分开定期重试消息(尤其是在性能方面)。此外,这提供了一个单独的队列,使您可以对这些错误消息进行分类(查看,清除,更改,手动重试等)... 这样的事情...有关更多详细信息,请参阅向消费者调查
//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);
    }
}   
如果您有更好的解决方案,请告诉我...祝您好运     
ActiveMQ中继现在支持基于代理的重新交付https://issues.apache.org/jira/browse/AMQ-3894     

要回复问题请先登录注册