Showing posts with label ActiveMQ. Show all posts
Showing posts with label ActiveMQ. Show all posts

Thursday, July 26, 2012

Apache ActiveMQ 5 Installation Guide for Ubuntu 11.10

If you are not familiar with Apache ActiveMQ, you better start with my previous post: Introduction: JMS (with) Spring and Apache ActiveMQ.

As I was installing Apache ActiveMQ on my Ubuntu 11.10 machine, I encountered a strange problem. If you go and read the official Installation Guide, it should be relatively easy to start ActiveMQ with the following commands after you download it:
 
$ cd [installation_dir]/

bin/activemq

OR

[insllation_dir]$: bin/activemq > /tmp/smlog  2>&1 &;
Note: /tmp/smlog may be changed to another file name.  

However, instead of running, it generated the following error message:

Configuration of this script:
    The configuration of this script can be placed on /etc/default/activemq or /home/amir/.activemqrc.
    To use addtional configurations for running multiple instances on the same operating system
    rename or symlink script to a name matching to activemq-instance-.
    This changes the configuration location to /etc/default/activemq-instance- and
    $HOME/.activemqrc-instance-. Configuration files in /etc have higher precedence. 

The issue as I observed was that for some reason, ApacheMQ had not created any configuration file, which supposed to be in /etc/default/apachemq. Therefor after extracting the apache-activemq-x.x.x.tar.gz file, run the following command:

$ [installation_dir]: ./bin/activemq setup activemq

and after that copy that activemq configuration file into /etc/default (Root privileges needed here):
 
$[installation_dir]: sudo cp activemq /etc/default

Now just run:
 
$[installation_dir]: bin/activemq start 
 
Now ActiveMQ should be up and running on http://localhost:8161/admin/.
Note: Remember not to close the terminal which you started ActiveMQ with, as it will terminate the ActiveMQ process or run it with the following command:

nohup bin/activemq > /tmp/smlog 2>&1 &

JMS (with) Spring and Apache ActiveMQ

0. Introduction

If you have worked with Java EE or you are willing to work with it, you probably have heard about Apache Active MQ. Since, for some reason, nearly each and every blog post that I have read on JMS and Spring (Including Spring In Action (Third Edition) and Just Spring (First Edition)) are using ActiveMQ. ActiveMQ is also recommended to be used while developing Java EE applications with Spring Framework.

So let us briefly explore what are advantages and disadvantages of using ApacheMQ.

First question that comes to mind is why it is so popular. apparently, you have variety of options as the following list proposes:
source: Wikipedia, http://en.wikipedia.org/wiki/Java_Message_Service#Provider_implementations


ActiveMQ seems to be quiet a popular option. As Aron Mulder mentioned in SpringSource webinar (Webinar Slides): it is open-source and community-based (as compared to JBoss MQ), its performance in being able to run standalone, or equally inside another process, application server, or Java EE application, its support for nearly everything JMS requires, and lastly its various extensions that integrates well into other products. Apart from what was mentioned in the Webinar, a key benefit of using ActiveMQ with Spring is that, Spring introduced  DefaultMessageListenerContainer object from API 2.0 and with that you only need to define an onMessage method where you can easily enable batch processing.


On disadvantages side, ActiveMQ can decrease performance, if you are not using a connection pool. As JmsTemplate asks for a connection per message and then closes it, therefore can put a huge processing load on the server.