簡體   English   中英

JMS隊列-在發送和接收對象消息之間有10秒的暫停

[英]JMS queue - 10 second pause between sending and receiving object message

我的服務器中有兩個應用程序,並通過ActiveMQ使用JMS在兩者之間發送消息。 我的兩個應用程序如下

Web服務-接受HTTP請求,進行驗證,然后發送要由其他應用程序執行的消息。

Exec App-接受對象消息,執行命令,將執行報告發送回Web服務以呈現給客戶端。

我的Exec應用程序在200毫秒內從Web服務接收消息,那里沒有問題。 但是,當我發送執行報告時,該消息可能在Web服務接收之前在隊列中掛起10秒鍾以上。 我為雙方的消費者使用了相同的代碼,所以我不確定是什么原因。

這是我在Exec App中的消息生成器-

public void createAndSendExecReport(OrderExecutionReport theReport){
    try {
        logger.debug("Posting exec report: " +theReport.getOrderId());
        this.excChannelMessageProducer.send(createMessage(theReport));
    } catch (JMSException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

[有一個createMessage方法將我的POJO轉換為目標消息]

 MessageListener listener = new MessageListener() {
            @Override
            public void onMessage(Message message) {
                logger.debug("Incoming execution report");
                try {
                    OrderExecutionReport report = (OrderExecutionReport)((ObjectMessage)message).getObject();
                    consumeExecutionReport(report);
                } catch (Exception e) {
                    logger.error("Message handling failed. Caught: " + e);
                    StringWriter sw = new StringWriter();
                    e.printStackTrace(new PrintWriter(sw));
                    logger.error(sw.toString());
                }
            }
        };

我收到日志消息“正在發送執行報告”,然后長達15秒鍾后Web服務中什么都沒有,直到最后我收到“傳入...”

這可能是什么原因?

確保在Exec App上運行了足夠的MDB,以便它們可以處理負載。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM