2015-08-27 93 views
1

我的服務器中有兩個應用程序,並通過ActiveMQ使用JMS在兩者之間發送消息。我的兩個應用程序如下所示:JMS隊列 - 在發送和接收對象消息之間暫停10秒

Web服務 - 接受HTTP請求,驗證,然後發送要由其他應用程序執行的消息。執行應用程序 - 接受對象消息,執行命令,將執行報告發送回Web服務以呈現給客戶端。

My Exec應用程序在200毫秒內接收來自Web服務的消息,在那裏沒有問題。但是,當我發送執行報告時,消息可以在隊列中掛起超過10秒鐘,然後由Web服務接收。我爲兩邊的消費者使用相同的代碼,所以我不確定原因是什麼。

這是我在Exec的應用程序消息生產者 -

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()); 
       } 
      } 
     }; 

我得到的日誌信息「發送執行報告「 然後在Web服務中沒有任何事情持續15秒,直到最後我得到」傳入...「

這可能是什麼原因造成的?

+0

是你使用某種調度的activeMQ嗎? – Vihar

回答

0

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