Thursday, October 15, 2009

Query Statistics for Apache ActiveMQ

Apache ActiveMQ has extensive support for JMX, but if you want to find out the running state of ActiveMQ from your application or from the one of the number of cross-language clients - your options are a bit limited.

ActiveMQ supports Broker plugins, which allows the default functionality to be extended, and new with version 5.3 of Apache ActiveMQ is a Statistics plugin, which enables statistics about the running broker, or Queues and Topics to be queried. To configure ActiveMQ to use the statistics plugin - just add the following to the ActiveMQ XML configuration:
...
<plugins>
<statisticsBrokerPlugin/>
</plugins>

The statistics plugin looks for messages sent to particular destinations. To query the running statistics of a the message broker, send an empty message to a Destination (Queue or Topic) named ActiveMQ.Statistics.Broker, and set the replyTo (jmsReplyTo if using JMS) field with the Destination you want to receive the result on. The statistics plugin will send a MapMessage filled with the statistics for the running ActiveMQ broker - e.g.

Queue replyTo = session.createTemporaryQueue();
MessageConsumer consumer = session.createConsumer(replyTo);


Queue query = session.createQueue("ActiveMQ.Statistics.Broker");
MessageProducer producer = session.createProducer(query);
Message msg = session.createMessage();
msg.setJMSReplyTo(replyTo);
producer.send(msg);


MapMessage reply = (MapMessage) consumer.receive();


for (Enumeration e = reply.getMapNames();e.hasMoreElements();) {
String name = e.nextElement().toString();
System.err.println(name+"="+reply.getObject(name));
}

You should see output like this:
vm=vm://localhost
memoryUsage=0
storeUsage=3330
tempPercentUsage=0
ssl=
openwire=tcp://localhost:50059
brokerId=ID:bigmac-50057-1253605065511-0:0
consumerCount=2
brokerName=localhost
expiredCount=0
dispatchCount=1
maxEnqueueTime=5.0
storePercentUsage=0
dequeueCount=0
inflightCount=1
messagesCached=0
tempLimit=107374182400
averageEnqueueTime=5.0
stomp+ssl=
memoryPercentUsage=0
size=10
tempUsage=0
producerCount=1
minEnqueueTime=5.0
dataDirectory=/Users/rajdavies/dev/projects/activemq/activemq-core/activemq-data
enqueueCount=10
stomp=
storeLimit=107374182400
memoryLimit=67108864



Similarly, if you want to query the statistics on a Destination, send a message to the Destination name, prepended with ActiveMQ.Statistics.Destination. For example, to retrieve the statistics on a Queue named test.foo send an empty message to the Queue ActiveMQ.Statistics.DestinationTest.Foo.
e.g.


Queue replyTo = session.createTemporaryQueue();
 MessageConsumer consumer = session.createConsumer(replyTo);
 Queue testQueue = session.createQueue("Test.Queue");
 MessageProducer producer = session.createProducer(null);
 Queue query = session.createQueue("
ActiveMQ.Statistics.Destination" +    testQueue.getQueueName());

 Message msg = session.createMessage();
       
  producer.send(testQueue,msg)
   msg.setJMSReplyTo(replyTo);
   producer.send(query,msg);
  MapMessage reply = (MapMessage) consumer.receive();
  assertNotNull(reply);
  assertTrue(reply.getMapNames().hasMoreElements());
       
  for (Enumeration e = reply.getMapNames();e.hasMoreElements();) {
            String name = e.nextElement().toString();
            System.err.println(name+"="+reply.getObject(name));
   }

       
You should see:



memoryUsage=0
dequeueCount=0
inflightCount=0
messagesCached=0
averageEnqueueTime=0.0
destinationName=queue://Test.Queue
size=1
memoryPercentUsage=0
producerCount=0
consumerCount=0
minEnqueueTime=0.0
maxEnqueueTime=0.0
dispatchCount=0
expiredCount=0
enqueueCount=1
memoryLimit=67108864


You can also use wildcards too, and receive a separate message for every destination matched.










Tuesday, October 13, 2009

Apache ActiveMQ 5.3 Released!

ActiveMQ 5.3 is finally released - and probably the biggest lesson is that going forward, we need to release far more frequently!

Here are some highlights:
  • We are making it a lot more obvious how to scales brokers vertically, to 10s of thousands of Queues/Topics - by including more example configurations.
  • New incarnation of KahaDB one of the persistent options we support. This provides vastly improved recovery times and scalability.
  • We've upgraded to the latest and greatest Apache Camel 2.0 - allowing for enterprise integration patterns to be run right inside the worlds most popular message broker
  • Support for getting broker statistics from languages other than Java
  • Message Expiration support directly in-store (any message store - and we support a few)
  • More extensive advisory messages
  • Enhancements to Master/Slave - including  more flexibility for starting slave brokers
  • NIO and SSL support for the mostly widely supported messaging transport - STOMP
  • over 300 issues resolved since version 5.2
Apache ActiveMQ is used in thousands of production environments for delivering high performance and reliable messaging under extreme load. Being an Apache project, it is supported by a diverse community of developers with extensive knowledge of building messaging solutions. Why not go and give it a spin ? - try the latest download!

Wednesday, July 01, 2009

Fuse Forge is now open!


The FUSE team has been hard at work over the last few months and here is an update on the great new capabilities that we're rolling out. We are entering a new phase in our community evolution by opening up FUSE Forge. The Forge is a collaborative environment for the development of open source projects related to FUSE and the Apache projects that they leverage. On FUSE Forge you can create and run a project, participate as a committer in one or more projects, or just browse the ever-growing library of components designed for FUSE. In the spirit of open source transparency the FUSE team has moved all internal development to the forge.

New Project Highlights:

FUSE Depot - FUSE Depot is a web-based tool for provisioning distributed applications on Apache Tomcat and FUSE ESB, our certified distribution of Apache ServiceMix. With FUSE Depot you can assemble bundles and libraries into applications, assign those applications to containers, and schedule deployments all from a central web console.

RestMQ - RestMQ defines an open, easy to integrate, loosely coupled, technology independent and interoperable messaging protocol so that you can use your web browser (or curl on the command line) to reliably send and consume messages.

Management - A set of FUSE management extensions using JMX and REST, visualized using FUSE HQ.

Actional Diagnostics - Actional Diagnostics helps developers build, test and deliver Web services for SOA, REST and POX by reducing the complexity of XML and making testing easy and accessible early in the product life cycle.

For more information on FUSE Forge see the FAQ!

Tuesday, May 26, 2009

Scaling ActiveMQ


Scaling ActiveMQ has come up a lot recently on the ActiveMQ users lists. One of the strengths of Apache ActiveMQ is its flexibility - but sometimes that's its curse too. Out of the box, ActiveMQ is configured to handle hundreds of very deep (contain 100 of millions of messages) - but its not the best configuration to scale queues horizontally (thousands of Queues on the same broker).

I've added a couple of FAQ entries to the Apache ActiveMQ site:


Something we need to address in the upcoming 5.3 release, is to provide more example configurations - to enable users to get a good head start on picking the right configuration for their use cases.

Thursday, February 12, 2009

Work Starting on Mixing ActiveMQ and SonicMQ

So we are getting some of the SonicMQ experts to dig in and help work on the next major version of ActiveMQ.  

The aim is to take performance and scalability to the next level - while ensuring that stability and reliability increases.  The SonicMQ guys have some great test environments which will enable us to provide even better quality code out of the door.

There's also some cool features that SonicMQ has like its Dynamic Routing Architecture and clustering that we are going to look to repurpose.

As ActiveMQ 6.0 is going to be a new architecture - it also enables us to look at supporting some more weird and wonderful wire protocols too (the invasive ones which force you to rewrite your broker to use them). 

The development work is being done at Apache - with Hiram setting the pace at the moment. Please feel free to jump in and help - :)
 

Friday, February 06, 2009

90's Retro is in!

Sometimes you just get distracted on some of the most mundane things - like design's of Logo's  Web Site etc.  Though when you start working for slightly larger organizations, you soon realize that there is a lot of things you don't know.

For example, I didn't realize that the 90's retro was back? I just came across this thread (pretty old I admit) about what constitutes a 90's look:
things like a swish, CAPITALIZATION , drop downs etc. 

So its refreshing that we have decided to be a head of the curve and will be adopting the 90's look again! Just of to get a mullet ....