其他两个软件之间还有一个中间件。在中间件中,我通过Apache Camel
路由Apache ActiveMQ
消息。 第一个软件使用中间件向第三个软件发送消息,第三个向第一个软件(使用中间件)回复消息。Apache Camel向ActiveMQ.DLQ发送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")
}
}
}
表示第3次软件(留言者):(这是像上面一个守护进程,我刚才复制的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);
}
}
})
;
}
}