【发布时间】:2019-11-17 07:43:29
【问题描述】:
我有 Apache Camel 客户端(消费者),它监听来自远程 ActiveMQ 主题的消息,我观察到它只在消费者运行时读取消息。
如果消费者没有收听并且生产者发送消息,他们将永远排队并被消费者挑选。
我希望我的客户在启动时应该阅读所有排队的消息
public static void main(String[] args) throws Exception
{
ActiveMQComponent amq = new ActiveMQComponent();
amq.setConnectionFactory( new ActiveMQConnectionFactory() );
amq.setUsername("admin");
amq.setPassword("admin");
amq.setBrokerURL("tcp://localhost:8161");
Main main = new Main();
main.bind("activemq", amq);
main.addRouteBuilder(new MyRouter());
main.run(args);
}
以下是路由器代码
public void configure() throws Exception
{
from("activemq:topic:saadtopic")
.transform(simple(" ${body}"))
.to("stream:out");
}
ActiveMQ=5.15.9 ApacheCamel=2.24.1
【问题讨论】:
-
您必须是durable subscriber。见
subscriptionDurableoption
标签: apache-camel jms activemq