我对 Camel 世界非常陌生,这就是为什么我请求你的帮助。 让我告诉你我想做的事情: 我有这个基本的 Camel 独立项目:
package maventest1;
public class JmsToSql {
private Main main;
public static void main(String[] args) throws Exception {
JmsToSql example = new JmsToSql();
example.boot();
}
public void boot() throws Exception {
main = new Main();
main.enableHangupSupport();
main.bind("foo", new MyBean());
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
main.bind("test-jms",JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
main.addRouteBuilder(new MyRouteBuilder());
main.run();
}
private static class MyRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
from("timer:foo?delay=2000")
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
//NOT SURE THIS IS THE RIGHT WAY
from("test-jms:queue:order1")
.to("test-jms:queue:order2");
}
})
.beanRef("foo");
}
}
public static class MyBean {
public void callMe() {
System.out.println("MyBean.calleMe method has been called");
}
}
}
我想做的就是从 activeMQ 队列中读取所有消息并将它们传递到另一个队列中。有人知道我该怎么做吗? 提前致谢=D
最佳答案
只需做一条从 JMS 到 JMS 的路由
private static class MyRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
from("test-jms:queue:order1")
.to("test-jms:queue:order2");
}
由于您是 Camel 新手,我建议您先阅读这篇文章
如果您想要优秀的文档和教程,请选择一本 Camel 书籍
关于java - Camel 和ActiveMQ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28859697/