Apache ActiveMQ Installation on Linux
Video Summary
Matt Pavlovich demonstrates the installation of Apache ActiveMQ on a Linux server, emphasizing the need for a local user and a recent Java JDK, specifically Java 11. He uses version 5.16.0 of ActiveMQ and pulls the installation media from Maven Central. Pavlovich creates a symlink for flexibility and uses the ActiveMQ script to start and stop the broker, test it with a producer and consumer, and verify settings like memory allocation and JMX access. He also sets the JMX password file to be readable only by the ActiveMQ user for security. The installation is validated by sending and receiving 1000 test messages.
Video Contents
Hey, it's Matt with an Uplink tech video today, I'm going to walk you through an installation of Apache ActiveMQ. Active MQ is a Java application, so when installing on a Linux server, it really has two requirements. It's going to need a local user and then a recent Java JDK. The version of ActiveMQ I'm using today is 5.16.0, and this added support for Java 11. So I'm going to go ahead and use a recent Java 11 JDK. And from a local user perspective, I went ahead and just added a user called ActiveMQ, but you can use any any user account that that fits in your environment.
So I'll just quickly validate that the job I've got installed is what I expect. There's our version 11, and then I created a download script that pulls the ActiveMQ media from Maven Central. I like pulling many open source installation packages from Maven because this easily adapts to an enterprise environment. So if you're building an Ansible job, an RPM or a Linux container, you can you can source it from a Maven repository and then quickly adapt this script to point to your local or your on-premise Maven repository that might be behind your firewall or your proxy. So we pull down the media and let's go ahead and use our favorite tar command. There we go. And that pretty much gets us the entire media down and installed. I mean, at this point ActiveMQ could run, and in most cases, it work fine in most applications.
I'm going to go ahead and add a symlink, though, because just as a best practice perspective, I like to be able to have location where I can have multiple copies of the media, and so this allows us to do upgrades and rollbacks. So I've created a simling called active, and we're going to work out of there. Great.
So ActiveMQ ships with a script in the bin folder called ActiveMQ, and it has a lot of tasks available to it. So if you give it the dash help, you'll see that you've got the several tasks and notes about what they do. We're going to use the start and stop as well as the producer, consumer and then this B stack command. So let's go ahead and test our starting and stopping. Great. The ActiveMQ key start command looks like it succeeded, and it's telling us that the process ID should be 20627, and we can quickly validate that. And just as a good practice, go ahead and stop it, make sure we get a nice, clean shutdown. Great. Start and Stop looks good.
Now I'm going to do a couple quick tuning settings. Since we're in an enterprise environment, most of the time, we're going to need applications to be able to send more messages than the default settings. So in ActiveMQ, there's a little file in the bin folder called env, and you'll find the memory settings are there. So in the ActiveMQ ops memory line, if you change that one to a four, this will allow ActiveMQ to use up to four gig of memory. And this is a good idea if you've got a server with at least a gig of RAM.
Now additionally, I want to enable the JMX access and require username and password. So JMX allows us to monitor and manage ActiveMQ remotely, and so we're going to want to take advantage of that, great, and then lastly, because we're using JMX and we want to have an authenticated access to that, or secured access, we need to change the JMX password file to make sure it's only readable by the ActiveMQ user as a security measure. So we're gonna use the Unix command chmod and set the 400 flag on that and now only the ActiveMQ user will be able to read that password file.
Okay, so let's start ActiveMQ up. We give it the start command. Now we can use the B stat command, and this is a way to quickly from the command line, make sure that the broker is running, and here we can validate that it found the process ID and we've got the broker running, and also tell us what the uptime is. So if you need some quick and dirty scripts or DevOp tools, this is something you can build around.
So now let's go ahead and send some test messages. If we use the producer task on the ActiveMQ script. It's just going to quickly fire 1000 messages up to a queue named test. Awesome. ActiveMQ, nice and fast. We got that done in a few seconds. Now when we run the bstat command, we can validate what we have on the queue. Great. So now we can see that we have a queue here called test, and that the enqueue count is 1000 and no messages have been dequeued, and that's exactly what we'd expect. Now we're going to run the consumer command, and this is going to take the messages off again, nice and fast, and we give it the B stack. Command, and we can see that the messages have been dequeued. The 1000 messages that were enqueued were also dequeued. So there you have it ActiveMQ installed and running.
Thank you for checking out this video. And if you have any questions, shoot us a note in the comments. Also all these scripts and the commands I used to get this installation going as always, are available on the uplink github site.