【发布时间】:2013-12-25 09:41:48
【问题描述】:
在其他两个软件之间有一个中间件。在中间件中,我通过Apache Camel 路由Apache ActiveMQ 消息。
第一个软件使用中间件向第三个软件发送消息,第三个软件将消息回复给第一个(使用中间件)。
1stSoftware <<=>> Middleware <<=>> 3rdSoftware
问题:
当我使用第一个将消息发送到中间件时,中间件将该消息直接发送到 ActiveMQ.DLQ 而第三个不能使用它!(有趣的是:当我将该消息复制到主队列时Admin panel of ActiveMQ,软件可以正常消费!)
有什么问题?!在我更改 Linux 日期之前它一直有效!!!!!!!
中间件是这样的:
@SuppressWarnings("deprecation")
public class MiddlewareDaemon {
private Main main;
public static void main(String[] args) throws Exception {
MiddlewareDaemon middlewareDaemon = new MiddlewareDaemon();
middlewareDaemon.boot();
}
public void boot() throws Exception {
main = new Main();
main.enableHangupSupport();
//?wireFormat.maxInactivityDuration=0
main.bind("activemq", activeMQComponent("tcp://localhost:61616")); //ToGet
main.bind("activemq2", activeMQComponent("tcp://192.168.10.103:61616")); //ToInOut
main.addRouteBuilder(new MyRouteBuilder());
System.out.println("Starting Camel(MiddlewareDaemon). Use ctrl + c to terminate the JVM.\n");
main.run();
}
private static class MyRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
intercept().to("log:Midlleware?level=INFO&showHeaders=true&showException=true&showCaughtException=true&showStackTrace=true");
from("activemq:queue:Q.Midlleware")
.process(new Processor() {
public void process(Exchange exchange) {
Map<String, Object> header = null;
try {
Message in = exchange.getIn();
header = in.getHeaders();
} catch (Exception e) {
log.error("Exception:", e);
header.put("Midlleware_Exception", e.getMessage() + " - " + e);
}
}
})
.inOut("activemq2:queue:Q.Comp2")
}
}
}
第三个软件(Replier):(这是一个类似上面的守护进程,我只是复制了RouteBuilder 部分)
private static class MyRouteBuilder extends RouteBuilder {
@Override
public void configure() {
intercept().to("log:Comp2?level=INFO&showHeaders=true&showException=true&showCaughtException=true&showStackTrace=true");
from("activemq:queue:Q.Comp2")
.process(new Processor() {
public void process(Exchange exchange) {
Message in = exchange.getIn();
Map<String, Object> headers = null;
try {
headers = in.getHeaders();
in.setBody(ZipUtil.compress(/*somResults*/));
} catch (Exception e) {
log.error("Exception", e);
in.setBody(ZipUtil.compress("[]"));
in.getHeaders().put("Comp2_Exception", e.getMessage() + " - " + e);
}
}
})
;
}
}
【问题讨论】:
标签: java jms activemq apache-camel