2013-12-08 134 views
0

其他两个软件之间还有一个中间件。在中间件中,我通过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); 
        } 
       } 
      }) 
      ; 
     } 
    } 

回答

0

如果只你改变的是一台服务器上的时间,那么这可能是问题所在。 要通过MQ进行通信以正常工作,所有相关主机系统都必须将其时钟设置为同步。对于ActiveMQ,响应队列有一个默认消息生存时间(我认为是30秒)。如果相对于运行ActiveMQ的主机,响应系统将来会超过30秒,那么ActiveMQ将立即过期消息并将其移至DLQ。

相关问题