Getting starting with JBoss A-MQ 7

JBoss A-MQ 7 is the new version of messaging family middleware products from Red Hat that are based in the Apache ActiveMQ Artemis upstream project. This new version is the result of the donation of the Red Hat own message product HornetQ to the Apache ActiveMQ  community in a joint effort to create  the new version of the already acclaimed ActiveMQ broker.

To getting starting with the JBoss A-MQ 7 messaging broker you need to first create a new account in Red Hat Developers program web site and download the last version of the version 7 branch of the product and unzip it in any folder that you want. I’ll call this folder as $ARTEMIS_HOME.

There are 3 steps that you need to do to start using the JBoss A-MQ 7 broker, they are:

  1. Create the broker;
  2. Start the broker;
  3. Use the broker.

Create the broker

When you unzip the JBoss A-MQ 7 package from the project website, there is no broker installed and configured in the installation directory, neither a default one. The package only contains scripts, libraries, examples and other support files that are used by the product, but it not contains a broker at all. So, the first thing that you need to do is to create a broker. To do that, you need to follow this steps:

Open a terminal window and go to $ARTEMIS_HOME folder, in this directory call this command (Here I’m using Linux bash style, if you are using Windows terminal, just convert  the command to Windows syntax):

$ bin/artemis create --user admin --password pass --role admin --allow-anonymous /opt/artemis/broker01

This command create a broker in /opt/artemis/broker01 folder, with the admin default user with admin role and pass as their password. This broker also accepts anonymous users to connect to the broker from localhost. I’ll call the folder where the broker is installed as $ARTEMIS_INSTANCE.

The options that I passed to create the broker is only the required ones. There is a lot of others options that you can use to better control the process of broker creation. If you want to know which options exists, run this command in $ARTEMIS_HOME folder:

$ bin/artemis help create

The $ARTEMIS_INSTANCE contains this folders:

  • bin : contains the broker scripts;
  • data: folder that contains the runtime persisted data, like messages sended, queues etc;
  • etc: contains the broker configurations files;
  • log: contains the log file generated by the broker;
  • tmp: contains temporary files

So, now you have a broker installed.

Start the broker

To start the broker you only need to run this command from the $ARTEMIS_INSTANCE folder.

$ bin/artemis run

Be aware that you run this command from $ARTEMIS_INSTANCE folder, not  $ARTEMIS_HOME instance. If you run this command from  $ARTEMIS_HOME folder, the command will not work.

After you run this command a console log will appears and the broker will be running.

Use the broker

Now it’s time to you to start use your broker, there is a lot of client libraries and protocols that you can use to start sending and receiving message from the broker, like default Java JMS clients, AMQP client, STOMP etc.

For now I’ll only use the default test only scripts to send and receving simple text messages from the broker instance.

To send 1000 messages to the broker I only need to run this command from $ARTEMIS_INSTANCE folder:

$ bin/artemis producer

The output of this command will be something like this:

Producer ActiveMQQueue[TEST], thread=0 Started to calculate elapsed time ...

Producer ActiveMQQueue[TEST], thread=0 Produced: 1000 messages
Producer ActiveMQQueue[TEST], thread=0 Elapsed time in second : 6 s
Producer ActiveMQQueue[TEST], thread=0 Elapsed time in milli second : 6356 milli seconds

To consume the 1000 messages that I sent, run this command:

$ bin/artemis consumer

The output of this command will be something like this:

Consumer:: filter = null
Consumer ActiveMQQueue[TEST], thread=0 wait until 1000 messages are consumed
Consumer ActiveMQQueue[TEST], thread=0 Received test message: 0
Consumer ActiveMQQueue[TEST], thread=0 Received test message: 1
Consumer ActiveMQQueue[TEST], thread=0 Received test message: 999
Consumer ActiveMQQueue[TEST], thread=0 Consumed: 1000 messages
Consumer ActiveMQQueue[TEST], thread=0 Consumer thread finished

Managment Console

One last thing that I want to show you. The JBoss A-MQ 7 have a management console that have a lot of visual tools to help you to manage the broker from a web interface without the need of the broker administration client libraries. The console are based in the project and is only available in JBoss A-MQ 7 project, not in Artemis version, and can be accessed only from localhost, the address are http://localhost:8161/hawtio/.

If you want access the console outside the localhost domain, you need to edit the $ARTEMIS_INSTANCE/etc/bootstrap.xml file and change the web bind address to the correspond bind IP that you want to expose your console.

Now you have a broker that is created, running and receiving and sending messages. Have fun 🙂

One thought on “Getting starting with JBoss A-MQ 7

Leave a Reply

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

You are commenting using your 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 )

Google+ photo

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

Connecting to %s