【问题标题】:Apache Camel sends ActiveMQ messages to ActiveMQ.DLQApache Camel 将 ActiveMQ 消息发送到 ActiveMQ.DLQ
【发布时间】: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


    【解决方案1】:

    如果您更改的唯一内容是其中一台服务器上的时间,那么这很可能是问题所在。 为了使 MQ 上的通信正常工作,所有相关主机系统的时钟设置必须同步。在 ActiveMQ 的情况下,响应队列有一个默认的消息生存时间(我认为是 30 秒)。如果响应系统相对于运行 ActiveMQ 的主机在未来 30 秒以上,则 ActiveMQ 将立即将消息过期并将其移至 DLQ。

    【讨论】:

      猜你喜欢
      • 2012-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-30
      • 2021-05-18
      • 1970-01-01
      • 2021-09-21
      • 1970-01-01
      相关资源
      最近更新 更多