How to build ActiveMQ


ActiveMQ Admin ConsoleBuilding ActiveMQ requires a certain minimal level of familiarity with maven. You can build ActiveMQ without a hitch, but once you do, where do you find it? Where does ActiveMQ gets installed. The apache ActiveMQ documentation simply does not bother to mention what the maven build will actually create. Here are the steps that I followed:

  1. Get the latest ActiveMQ sources:
    svn co https://svn.apache.org/repos/asf/activemq/trunk activemq

    This will create a sub-folder called activemq wherever you’ve run the above snv command from.

  2. Get latest version of Maven binaries (2.0.7). Unzip and copy the maven folder to its final destination (where ever you deploy various apache libs). Add .../maven-2.0.7/bin to your PATH environment variable. Check to make sure that maven is installed properly:
    
    $ mvn --version
    Maven version: 2.0.7
    Java version: 1.5.0_07
    OS name: "mac os x" version: "10.4.9" arch: "i386"
    
  3. Build ActiveMQ:
    MAVEN_OPTS=-Xmx800m mvn clean install -Dmaven.test.skip=true

    If you want to also run the test cases, then omit the -D option above. With the current trunk sources, however, two of the test cases fail to run and the build “fails”. Building without the tests takes about 3 minutes on my laptop and with tests takes an hour.

  4. When the build completes, you should see the following lines on the console:
    
    [INFO]------------------------------------------------------------------------
    [INFO] Reactor Summary:
    [INFO]------------------------------------------------------------------------
    [INFO] ActiveMQ .............................................. SUCCESS [3.372s]
    [INFO] ActiveMQ User Guide ................................... SUCCESS [14.061s]
    [INFO] ActiveMQ :: JAAS ...................................... SUCCESS [2.503s]
    [INFO] Openwire Generator .................................... SUCCESS [0.677s]
    [INFO] ActiveMQ :: Core ...................................... SUCCESS [13.350s]
    [INFO] ActiveMQ :: Console ................................... SUCCESS [0.923s]
    [INFO] ActiveMQ :: File Server ............................... SUCCESS [1.726s]
    [INFO] ActiveMQ :: JPA Message Store ......................... SUCCESS [2.287s]
    [INFO] ActiveMQ :: Optional .................................. SUCCESS [0.688s]
    [INFO] ActiveMQ :: RA ........................................ SUCCESS [0.700s]
    [INFO] ActiveMQ :: RAR ....................................... SUCCESS [1.781s]
    [INFO] ActiveMQ :: Atomikos System Test ...................... SUCCESS [2.380s]
    [INFO] ActiveMQ Tooling ...................................... SUCCESS [0.012s]
    [INFO] ActiveMQ :: Memory Usage Test Plugin .................. SUCCESS [0.968s]
    [INFO] ActiveMQ :: Performance Test Plugin ................... SUCCESS [0.660s]
    [INFO] ActiveMQ :: StartUp Plugin ............................ SUCCESS [0.307s]
    [INFO] ActiveMQ :: Web ....................................... SUCCESS [0.492s]
    [INFO] ActiveMQ :: Web Demo .................................. SUCCESS [1.628s]
    [INFO] ActiveMQ :: XMPP ...................................... SUCCESS [2.779s]
    [INFO] ActiveMQ :: Web Console ............................... SUCCESS [2.623s]
    [INFO] ActiveMQ :: Assembly .................................. SUCCESS [1:12.374s]
    [INFO] ------------------------------------------------------------------------
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESSFUL
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 2 minutes 8 seconds
    [INFO] Finished at: Sat Jun 23 07:38:42 PDT 2007
    [INFO] Final Memory: 35M/191M
    [INFO] ------------------------------------------------------------------------
    
  5. OK now the build has been successfully completed. But where is it? According to maven documentation “vast majority of projects can be build using the command mvn clean install. This commands builds the project and installs it in the local repository“. OK where is that? Finding this location requires searching the maven site. I came across this handy guide to maven 2. The command line option -X generates a bit more useful information, e.g., the locations of the local repositories (not sure why two folders are created): ~/.maven/repository and ~/.m2/repository. Now if you view the local repository ~/.maven/repository, you should see the following two folders: org.apache.activemq and org.apache.activemq.tooling. The ~/.m2/repository is another matter. It contains almost all of the open source java projects that you may have ever heard of. There are 72 folders in this repository:
    
    $ ls
    activemq                commons-logging         junit
    activesoap              commons-net             log4j
    annogen                 commons-pool            net
    ant                     commons-primitives      opensymphony
    antlr                   commons-validator       org
    aopalliance             directory               oro
    avalon-framework        directory-asn1          plexus
    axion                   directory-network       qdox
    axis                    directory-protocols     regexp
    batik                   directory-shared        rome
    bouncycastle            doxia                   saxon
    bsh                     emma                    saxpath
    cglib                   fop                     stax
    checkstyle              geronimo-spec           taglibs
    classworlds             groovy                  velocity
    com                     hsqldb                  xalan
    commons-beanutils       javacc                  xerces
    commons-cli             javax                   xml-apis
    commons-codec           jaxen                   xml-resolver
    commons-collections     jdbm                    xmlbeans
    commons-dbcp            jdom                    xmlpull
    commons-httpclient      jivesoftware            xsddoc
    commons-io              jmock                   xstream
    commons-lang            jrms
    

    After a bit more hunting I found it! The maven build creates the folder:
    ~/.maven/repository/org.apache.activemq/tar.gz
    It is here that you’ll find what you’ll need to actually deploy and run activemq. This folder contains two files:

    apache-activemq-5.0-SNAPSHOT-src.tar.gz
    apache-activemq-5.0-SNAPSHOT.tar.gz

  6. Decompress apache-activemq-5.0-SNAPSHOT.tar.gz to a location of your choice. This will create the folder apache-activemq-5.0-SNAPSHOT. The bin sub-folder contains the commands that you’ll need to start the activemq broker. The bin folder will contain the following:
    
    $ ls -F bin
    activemq*       activemq-admin* linux/
    macosx/         run.jar         wrapper.jar
    
  7. Start the broker: ./bin/activemq . From the console you’ll see a few log lines that end in:
    
    INFO  WebConsoleStarter  - ActiveMQ WebConsole initialized.
    INFO  /admin             - Loading WebApplicationContext for Spring FrameworkServlet 'dispatcher'
    INFO  log                - ActiveMQ Console at http://0.0.0.0:8161/admin
    INFO  log                - ActiveMQ Web Demos at http://0.0.0.0:8161/demo
    INFO  log                - Started SelectChannelConnector @ 0.0.0.0:8161
    
  8. Now you can visit the ActiveMQ Console (http://0.0.0.0:8161/admin) or the Web Demos (http://0.0.0.0:8161/demo) with your browser. Next you’ll need to configure activemq, e.g. to use MySQL, …

    The build also creates a convenient command line tool (I think) for macosx and linux:

    
    $ ./macosx/activemq
    Usage: ./macosx/activemq { console | start | stop | restart | status | dump }
    

    On OS X, at least, when you run this command it just says that broker started, but it is actually not running. Needs more investigation…

6 Responses to “How to build ActiveMQ”

  1. Sean Corfield Says:

    I hear a lot of complaints about Maven for exactly this sort of poorly documented, counter-intuitive behavior so it’s great to see articles like this explaining things in detail!

    I don’t remember building AMQ so I must have found a Mac OS X binary (or maybe a Linux binary that just happens to run on OS X?).

    I’ve been using AMQ quite a lot recently and built a new event gateway for ColdFusion that makes JMS integration extremely simple, with full support for queues, topics, transacted message consumption, message selectors etc etc.

  2. mjh Says:

    > Building without the tests takes about 3 minutes on my laptop

    As long as you got a populated repository already, otherwise downloading the required repository files will take some time (and some megabytes of HD space)… the two directories are due to the neccessity to create both of maven1 and maven2 repositories during build time.

    If you hear/know of any method to set the location of maven2 repository directory by either setting an environment variable or command line option please let me know.

  3. Arun Says:

    I have installed the latest release of activemq. i have made the configuration changes required.

    I am new to this tech and am not able to ascertain if my new version is running or the old one. on simpler words, how do i check the version of activemq running on my linux server?

    Thanks
    Arun

  4. Installing ActiveMQ From Source On Mac OS X Leopard Says:

    […] that I built ActiveMQ from source, where is it installed? It took me awhile to figure this out, but How to build ActiveMQ from note19.com has some useful information to help out on […]

  5. Zing Says:

    I really dislike this aspect of Maven in general. Why do I want these files in .m2 in only my own user’s home directory? And related, why do I have to fetch huge quantities of dependencies which are only needed at compile-time? And then why do _these_ sit around cluttering up my hard disk…

    It also causes hell if someone who isn’t using Maven wants to build Active MQ as part of their vendor build. Because this particular project doesn’t provide equivalent Ant build files, it means installing a whole second build system just for this one project. 😦

    And granted they had a reason — the Ant Plugin for Maven fails trying to do the conversion.

  6. serg Says:

    Cool !
    I spent half a day to install activemq
    Your article helped me to solve all problems

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: