2012-06-06 118 views
1

在ActiveMQ中,我能否檢測消息從發佈者傳遞給訂閱者需要多少時間? 或者我可以看到消息從發佈服務器到主題(JMS服務)並從(JMS服務)主題到Subsriber的單獨計時?ActiveMQ消息傳輸時間

回答

0

有一個Maven plugin for AMQ performance testing,它可能是你正在尋找。

否則,您可以通過使用一些負載測試工具(如Apache jMeter)進行一些測量,然後看看您可以讀/寫多少條消息/秒。

請注意,如果您堅持不懈和/或事務處理,您將會有相當大的差異。

更新:

你可以通過配置的conf/log4j.properties和設置可能做日誌的內容:數據

log4j.rootLogger=TRACE, logfile, console 

然後/ activemq.log你可以得到一些信息,認沽信息。數字代表的並不是很明顯,所以你應該確保定義一個測試場景。下面的時間戳是從提出到通過HermesJMS隊列(myQueue中)到ActiveMQ的消息:

2012-06-06 16:31:19,979 | DEBUG | localhost adding consumer: ID:GOTL19946-53234- 
1338993070006-0:2:3:1 for destination: queue://myqueue |org.apache.activemq.broker.region.AbstractRegion | ActiveMQ Transport: tcp:///127.0.0.1:53236 
2012-06-06 16:31:19,989 | DEBUG | queue://myqueue add sub: QueueBrowserSubscription: consumer=ID:GOTL19946-53234-1338993070006-0:2:3:1, destinations=0, dispatched=0, delivered=0, pending=0, dequeues: 0, dispatched: 0, inflight: 0 | org.apache.activemq.broker.region.Queue | ActiveMQ Transport: tcp:///127.0.0.1:53236 
2012-06-06 16:31:19,989 | DEBUG | myqueue toPageIn: 1, Inflight: 0, pagedInMessages.size 0, enqueueCount: 1, dequeueCount: 0 | org.apache.activemq.broker.region.Queue | Queue:myqueue 
2012-06-06 16:31:19,989 | TRACE | QueueStorePrefetch513024249 - fillBatch | org.apache.activemq.broker.region.cursors.AbstractStoreCursor | Queue:myqueue 
2012-06-06 16:31:19,989 | DEBUG | dispatch to browser: QueueBrowserSubscription: consumer=ID:GOTL19946-53234-1338993070006-0:2:3:1, destinations=1, dispatched=0, delivered=0, pending=0, already dispatched/paged count: 1 | org.apache.activemq.broker.region.Queue | Queue:myqueue 
2012-06-06 16:31:19,999 | TRACE | ID:GOTL19946-53234-1338993070006-0:2:3:1 dispatched: ID:GOTL19946-53234-1338993070006-0:2:2:1:1 - queue://myqueue, dispatched: 1, inflight: 1 | org.apache.activemq.broker.region.PrefetchSubscription | ActiveMQ Connection Dispatcher: /127.0.0.1:53236 
2012-06-06 16:31:19,999 | TRACE | ack:MessageAck {commandId = 13, responseRequired = false, ackType = 2, consumerId = ID:GOTL19946-53234-1338993070006-0:2:3:1, firstMessageId = ID:GOTL19946-53234-1338993070006-0:2:2:1:1, lastMessageId = ID:GOTL19946-53234- 1338993070006-0:2:2:1:1, destination = queue://myqueue, transactionId = TX:ID:GOTL19946- 53234-1338993070006-0:2:2, messageCount = 1, poisonCause = null} | org.apache.activemq.broker.region.PrefetchSubscription | ActiveMQ Transport: tcp:///127.0.0.1:53236 
2012-06-06 16:31:19,999 | DEBUG | commit: TX:ID:GOTL19946-53234-1338993070006-0:2:2 syncCount: 1 | org.apache.activemq.transaction.LocalTransaction | ActiveMQ Transport: tcp:///127.0.0.1:53236 
2012-06-06 16:31:19,999 | DEBUG | myqueue toPageIn: 0, Inflight: 1, pagedInMessages.size 1, enqueueCount: 1, dequeueCount: 0 | org.apache.activemq.broker.region.Queue | Queue:myqueue 
2012-06-06 16:31:20,049 | DEBUG | localhost removing consumer: ID:GOTL19946-53234-1338993070006-0:2:3:1 for destination: queue://myqueue | org.apache.activemq.broker.region.AbstractRegion | ActiveMQ Transport: tcp:///127.0.0.1:53236 
2012-06-06 16:31:20,049 | DEBUG | queue://myqueue remove sub: QueueBrowserSubscription: consumer=ID:GOTL19946-53234-1338993070006-0:2:3:1, destinations=1, dispatched=0, delivered=1, pending=0, lastDeliveredSeqId: 67, dequeues: 0, dispatched: 1, inflight: 0 | org.apache.activemq.broker.region.Queue | ActiveMQ Transport: tcp:///127.0.0.1:53236 
2012-06-06 16:31:20,049 | DEBUG | myqueue toPageIn: 0, Inflight: 0, pagedInMessages.size 1, enqueueCount: 1, dequeueCount: 0 | org.apache.activemq.broker.region.Queue | Queue:myqueue 
+0

好的。因此,不能添加代碼級別的調試,以獲得所有消息傳輸的平均時間n? – Aryan

+0

添加了一些信息,如何從activemq日誌中抽樣調試輸出。不知道這是你想要的。 –

2

當JMS消息在消費者到達時,你可以看看到JMSTimestamp頭屬性。根據Javadoc:

JMSTimestamp標題字段包含消息被傳遞的時間 off要發送。

然後,你可以簡單地從當前系統時間減去JMSTimestamp和飛行計算time taken通過JMS消息。