Saturday 4 August 2018

Installing and setting up ActiveMQ

In this post, you are going to learn.
a.   Setting up ActiveMQ
b.   Running ActiveMQ instance
c.   Testing the Installation
AcvtieMQ requires Java 1.7 or higher. Make sure you installed and setup java environment in your system.

Below post helps you in setting up Java.

Make sure, you set the JAVA_HOME environment variable to the directory where the JRE is installed.

Setting up ActiveMQ
Download latest stable release of ActiveMQ from below location.

At the time of writing this tutorial ‘ActiveMQ 5.15.3’ is the stable one.

There are two kinds of executables available, one for windows and other for Linux systems.

Installing ActiveMQ in windows
Extract the downloaded zip file.

The extraction contains below kind of directory structure.




The bin directory contains executable of activeMq. Add the bin directory to the system path.

Add AciveMQ bin path to system path in windows.
Right click on my computer -> properties.




Click on ‘Advanced system settings’.



Go to Advanced tab and click on ‘Environment Variables’ button.


Go to ‘System variables’ section, select the variable ‘Path’ and click on Edit button.




Add ActiveMQ bin directory path there.

Installing ActiveMQ in Linux
It is same as windows, extract the downloaded binary and add the ActiveMQ bin directory path to system path.

Running ActiveMQ instance
Open command prompt (or) terminal, and run the command ‘activemq start’.

When I ran above command, I end up in below error.
Failed to bind to server socket: tcp://0.0.0.0:61616

It is because, the port 61616 is already is use by some other process. There are two options to solve this problem.
a.   Kill the process that is running on port 61616.
b.   Change the port number

I chose second option and change the port number to 5050.

How to change the port number?
Go to <ACTIVEMQ_INSTALL_DIRECTORY>/conf folder.

Open ‘activemq.xml’ file and search for the port 61616 and replace it with 5050.

<transportConnector name="openwire" uri="tcp://0.0.0.0:5050?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
       
Now rerun the command ‘activemq start’.

C:\Users\krishna\Documents\Study\Active MQ\ActiveMQ Working Dir>activemq start
Java Runtime: Oracle Corporation 1.8.0_102 C:\Program Files\Java\jdk1.8.0_102\jre
  Heap sizes: current=1005056k  free=989327k  max=1005056k
    JVM args: -Dcom.sun.management.jmxremote -Xms1G -Xmx1G -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=C:\Users\krishna\Documents\Study\Active MQ\softwares\apache-activemq-5.15.3-bin\apache-activemq-5.15.3\bin\..\conf\login.config -Dactivemq.classpath=C:\Users\krishna\Documents\Study\Active MQ\softwares\apache-activemq-5.15.3-bin\apache-activemq-5.15.3\bin\..\conf;C:\Users\krishna\Documents\Study\Active MQ\softwares\apache-activemq-5.15.3-bin\apache-activemq-5.15.3\bin\../conf;C:\Users\krishna\Documents\Study\Active MQ\softwares\apache-activemq-5.15.3-bin\apache-activemq-5.15.3\bin\../conf; -Dactivemq.home=C:\Users\krishna\Documents\Study\Active MQ\softwares\apache-activemq-5.15.3-bin\apache-activemq-5.15.3\bin\.. -Dactivemq.base=C:\Users\krishna\Documents\Study\Active MQ\softwares\apache-activemq-5.15.3-bin\apache-activemq-5.15.3\bin\.. -Dactivemq.conf=C:\Users\krishna\Documents\Study\Active MQ\softwares\apache-activemq-5.15.3-bin\apache-activemq-5.15.3\bin\..\conf -Dactivemq.data=C:\Users\krishna\Documents\Study\Active MQ\softwares\apache-activemq-5.15.3-bin\apache-activemq-5.15.3\bin\..\data -Djava.io.tmpdir=C:\Users\krishna\Documents\Study\Active MQ\softwares\apache-activemq-5.15.3-bin\apache-activemq-5.15.3\bin\..\data\tmp
Extensions classpath:
  [C:\Users\krishna\Documents\Study\Active MQ\softwares\apache-activemq-5.15.3-bin\apache-activemq-5.15.3\bin\..\lib,C:\Users\krishna\Documents\Study\Active MQ\softwares\apache-activemq-5.15.3-bin\apache-activemq-5.15.3\bin\..\lib\camel,C:\Users\krishna\Documents\Study\Active MQ\softwares\apache-activemq-5.15.3-bin\apache-activemq-5.15.3\bin\..\lib\optional,C:\Users\krishna\Documents\Study\Active MQ\softwares\apache-activemq-5.15.3-bin\apache-activemq-5.15.3\bin\..\lib\web,C:\Users\krishna\Documents\Study\Active MQ\softwares\apache-activemq-5.15.3-bin\apache-activemq-5.15.3\bin\..\lib\extra]
ACTIVEMQ_HOME: C:\Users\krishna\Documents\Study\Active MQ\softwares\apache-activemq-5.15.3-bin\apache-activemq-5.15.3\bin\..
ACTIVEMQ_BASE: C:\Users\krishna\Documents\Study\Active MQ\softwares\apache-activemq-5.15.3-bin\apache-activemq-5.15.3\bin\..
ACTIVEMQ_CONF: C:\Users\krishna\Documents\Study\Active MQ\softwares\apache-activemq-5.15.3-bin\apache-activemq-5.15.3\bin\..\conf
ACTIVEMQ_DATA: C:\Users\krishna\Documents\Study\Active MQ\softwares\apache-activemq-5.15.3-bin\apache-activemq-5.15.3\bin\..\data
Loading message broker from: xbean:activemq.xml
 INFO | Refreshing org.apache.activemq.xbean.XBeanBrokerFactory$1@4cc0edeb: startup date [Sun Apr 22 00:48:39 IST 2018]; root of context hierarchy
 INFO | Using Persistence Adapter: KahaDBPersistenceAdapter[C:\Users\krishna\Documents\Study\Active MQ\softwares\apache-activemq-5.15.3-bin\apache-activemq-5.15.3\bin\..\data\kahadb]
 INFO | KahaDB is version 6
 INFO | PListStore:[C:\Users\krishna\Documents\Study\Active MQ\softwares\apache-activemq-5.15.3-bin\apache-activemq-5.15.3\bin\..\data\localhost\tmp_storage] started
 INFO | Apache ActiveMQ 5.15.3 (localhost, ID:INLN50911363A-51025-1524338320986-0:1) is starting
 INFO | Listening for connections at: tcp://INLN50911363A:5050?maximumConnections=1000&wireFormat.maxFrameSize=104857600
 INFO | Connector openwire started
 INFO | Listening for connections at: amqp://INLN50911363A:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600
 INFO | Connector amqp started
 INFO | Listening for connections at: stomp://INLN50911363A:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600
 INFO | Connector stomp started
 INFO | Listening for connections at: mqtt://INLN50911363A:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600
 INFO | Connector mqtt started
 WARN | ServletContext@o.e.j.s.ServletContextHandler@282cb7c7{/,null,STARTING} has uncovered http methods for path: /
 INFO | Listening for connections at ws://INLN50911363A:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600
 INFO | Connector ws started
 INFO | Apache ActiveMQ 5.15.3 (localhost, ID:INLN50911363A-51025-1524338320986-0:1) started
 INFO | For help or more information please see: http://activemq.apache.org
 WARN | Store limit is 102400 mb (current store usage is 0 mb). The data directory: C:\Users\krishna\Documents\Study\Active MQ\softwares\apache-activemq-5.15.3-bin\apache-activemq-5.15.3\bin\..\data\kahadb only has 43265 mb of usable space. - resetting to maximum available disk space: 43265 mb
 WARN | Temporary Store limit is 51200 mb (current store usage is 0 mb). The data directory: C:\Users\krishna\Documents\Study\Active MQ\softwares\apache-activemq-5.15.3-bin\apache-activemq-5.15.3\bin\..\data only has 43265 mb of usable space. - resetting to maximum available disk space: 43265 mb
 INFO | No Spring WebApplicationInitializer types detected on classpath
 INFO | ActiveMQ WebConsole available at http://0.0.0.0:8161/
 INFO | ActiveMQ Jolokia REST API available at http://0.0.0.0:8161/api/jolokia/
 INFO | Initializing Spring FrameworkServlet 'dispatcher'
 INFO | No Spring WebApplicationInitializer types detected on classpath
 INFO | jolokia-agent: Using policy access restrictor classpath:/jolokia-access.xml

Testing the Installation
Open the administrative interface by firing the URL:
Login: admin
Password: admin


Give the username and password as ‘admin’ and click on OK button.

You can able to see below kind of window.


Navigate to Queues.


Add a queue name ‘Hello World’ and click create.



“Hello World’ queue will be created.


Send test message by clicking on "Send to"




Add some message body. For example, I added ‘First Message sending to ActiveMQ queue’ and click on ‘Send’ button.


Now, you can able to see ‘Number Of Pending Messages’ as 1.





That’s it, your ActiveMQ setup is working perfectly….:)

Previous                                                 Next                                                 Home

No comments:

Post a Comment