MENU

Tuesday, 27 January 2015

Apache ActiveMQ Apollo Quick Test

Ok, so there's some buzz about activemq; I even bought a book some time ago and well, never got past the introduction as I don't really have use-cases for it but today some fellow worker mentioned it to me. He kind of seemed to love it. That fellow worker, let's call him AKN :P, was amazed of the speed despite the other opinions he obviously read or heard (I didn't).

And because I love speed I decided to go for a ride with Apache ActiveMQ Apollo. Apollo what? Yea, this is actually ActiveMQ but faster. Bummer! No, no bummer! Just faster :P. It's still a queue though.

Here's a short description:
ActiveMQ Apollo is a faster, more reliable, easier to maintain messaging broker built from the foundations of the original ActiveMQ.
Well, how can I _not_ download this? Ha! I'm faster. Me! Bamm! But take care; it's the first time I installed and used activemq so be prepared and don't believe me. I btw. used Apollo 1.7.

If you don't care, here's a short introduction to Apache ActiveMQ Apollo:

Download Apache Apollo at: http://activemq.apache.org/apollo/download.html
Unzip it...easy :P

Create the broker (I expect you to be in the extracted folder):

This will create a subdirectory in "bin": testbroker
In there you will find an executable file "apollo-broker" ...

Start the broker!

You will see some gibberish but don't worry, or if you worry, get a drink, a cigarette or sex, or all of that (not in that order though!) and then go on. At the end of the gibberish you will see something like:
INFO | Accepting connections at: tcp://0.0.0.0:61613
INFO | Accepting connections at: tls://0.0.0.0:61614
INFO | Accepting connections at: ws://0.0.0.0:61623/
INFO | Accepting connections at: wss://0.0.0.0:61624/
INFO | Administration interface available at: https://127.0.0.1:61681/
INFO | Administration interface available at: http://127.0.0.1:61680/
Oh, cool! The broker is running. Don't be scared about the 0.0.0.0; this is you! The default configuration sets the user to "admin" and the password to "password". The default port is 61613. There's also a web administration panel available at: http://127.0.0.1:61680/ the default user is "admin" and the password is "password". The UI actually looks a lot better than the one from activemq. You can see which "topics" are "running" or "available". There's the "topics" tab. Just click around. It won't explode.

Here's a screenshot of my console:

apolloconsole So? eh...yea...now it's up to you...you need a:

- Listener
- Publisher

Imagine the Listener as a "router" in web development; you tell the listener that "he" has to listen for "things" on a specific "route" like e.g. "/topic/beer". The "/topic" part seems to be mandatory. I tried to omit it but it then fails. Let's just have a look at a simple listener that listens for stomp messages on "/topic/beer"; in activemq slang, our "route" is called a "topic". Cool! well, no :P.

Listener.java

This is an easy and simple example of a listener. I cut it down to demonstrate apollo.

Publisher.java

You can find the sources on github: https://github.com/schipplock/activemqtest

If you already got apollo running, you can play around with my "code" without actually compiling it. All you need is this default apollo setup and java of course. You can find my jars in the releases.

- activemqtest_listener.jar
- activemqtest_publisher.jar

First start the listener, then the publisher. When you execute the publisher, have a look at the listener window. You will notice that the publisher is finished in milliseconds while the listener is still processing. There you can see a real and live queue :).

apollo_inaction

I start to like it.