We help IT Professionals succeed at work.
Get Started

How to send JMS message to a queue on a standalone activemq

Last Modified: 2012-05-11
I'm trying to set up a jms queue on a standalone ActiveMQ that needs to be reachable across a the network. I'd appreciate your help.

This ActiveMQ provider is supposed to be running on a linux server.

I downloaded the activemq tar file (v 5.4.2)  and installed it to the server with the following steps:
- untar-ed it,
- did minimal configuration to set ACTIVEMQ_BASE and ACTIVEMQ_HOME,
- then started it with the ./activemq start command from the command line
- checked <activemq-home>/data/activemq.log for the "INFO | .... started" line.

At this point, I *think* I have a activemq server up and running on this Linux machine.

I tried to use the following sample code (copied from the interweb) to send a message to the above jms server, but it just sit and hang:
        ConnectionFactory connectionFactory =
            new ActiveMQConnectionFactory("failover://tcp://<server-name>:61616");
        Connection connection = connectionFactory.createConnection();

        System.out.println("Trying to make connection");
        System.out.println("Connection established");
        Session session = connection.createSession(false,

        Destination destination = session.createQueue("TESTQUEUE");
        TextMessage message = session.createTextMessage("TEST MESSAGE");
        System.out.println("Sent message '" + message.getText() + "'");


Open in new window

I tried the exact same code against an activemq server on my local machine, where ActiveMQ ConnectionFactory is initialized with "failover://tcp://localhost:61616", and the code executed fine.

But when i changed initialization to have the linux server's name "failover://tcp://<server-name>:61616"; the code never made pass the

Open in new window


Here are a few of my questions to start (i have a whole lot of 'em):
1. Did I set up activeMQ right for it to be used the way I intend to use it?

2. If not, could you please point me to the right direction as to how to set it up right for the purpose?

3.If it is set up right, there must me something wrong with the way i'm trying to connect. what is the correct way to send a message?

I'm completely clueless in this area, no details is too small.

Thanks for your help.

Watch Question
Awarded 2011
Awarded 2011
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE