2017-05-04 7 views
0

BrokerFilterクラスのsend()メソッドをオーバーライドしたいと思います。"org.apache.activemq.command.Message"からactievmqキューのサイズを取得するにはどうしたらいいですか?

このメソッドには、ProducerBrokerExchangeとMessageという2つのパラメータがあります。

これらの2つのパラメータから宛先キューのサイズを取得できますか。

私はactivemq-all-5.13.2.jarを使用しています。

答えて

1

あなたはStatisticsBrokerPluginを参照することができます。

コードは他の人が必要な場合にここにあります。

ActiveMQDestination msgDest = messageSend.getDestination(); 
    String physicalName = msgDest.getPhysicalName(); 
    logger.info("dest: " + physicalName); 

    ActiveMQDestination queryDestination = ActiveMQDestination.createDestination(physicalName, msgDest.getDestinationType()); 
    Set<Destination> destinations = getDestinations(queryDestination); 
    logger.info(destinations); 
    long count = 0; 
    for (Destination dest : destinations) { 
     DestinationStatistics stats = dest.getDestinationStatistics(); 
     if (stats != null) { 
      count = stats.getMessageSize().getCount(); 
      logger.info("size: " + count); 
     } 
    } 
0

あなたが使用することができます。

BrokerFilter.getRegionDestination().getDestinationStatistics().getMessages().getCount(); 

あなたがorg.apache.activemq.broker.region.DestinationStatisticsにすべてこの統計情報を持っている:

enqueues = new CountStatisticImpl("enqueues", "The number of messages that have been sent to the destination"); 
dispatched = new CountStatisticImpl("dispatched", "The number of messages that have been dispatched from the destination"); 
dequeues = new CountStatisticImpl("dequeues", "The number of messages that have been acknowledged from the destination"); 
forwards = new CountStatisticImpl("forwards", "The number of messages that have been forwarded to a networked broker from the destination"); 
inflight = new CountStatisticImpl("inflight", "The number of messages dispatched but awaiting acknowledgement"); 
expired = new CountStatisticImpl("expired", "The number of messages that have expired"); 

consumers = new CountStatisticImpl("consumers", "The number of consumers that that are subscribing to messages from the destination"); 
consumers.setDoReset(false); 
producers = new CountStatisticImpl("producers", "The number of producers that that are publishing messages to the destination"); 
producers.setDoReset(false); 
messages = new CountStatisticImpl("messages", "The number of messages that that are being held by the destination"); 
messages.setDoReset(false); 
messagesCached = new PollCountStatisticImpl("messagesCached", "The number of messages that are held in the destination's memory cache"); 
processTime = new TimeStatisticImpl("processTime", "information around length of time messages are held by a destination"); 
blockedSends = new CountStatisticImpl("blockedSends", "number of messages that have to wait for flow control"); 
blockedTime = new TimeStatisticImpl("blockedTime","amount of time messages are blocked for flow control"); 
messageSize = new SizeStatisticImpl("messageSize","Size of messages passing through the destination"); 
+0

BrokerFilterにはgetRegionDestinationメソッドがないようです。 MessageにはgetRegionDestinationメソッドがありますが、実行時にはnullしか取得できません。 – Solo

+0

私はactivemq-all-5.13.2.jarを使用しています – Solo

関連する問題