Link to home
Start Free TrialLog in
Avatar of NuttySquirrel

asked on

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

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.

Avatar of for_yan
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NuttySquirrel


Thanks for answering.

Can I infer from your answer that you dont think anything is wrong with my ActiveMQ setup?

I tried adding those transport options you mentioned. I dont think those options help with making the connection, although  they will be handy to know of in the future.

I think the port 61616 maybe blocked by the firewall (attempt to telnet into that port is hung and timed out). I'll have to check on that with the sysadmin on Monday.

I'll be back on Monday with a verdict on that port. Hopefully, it is the port that's causing my troubles.
Well, taking into acount that locally it works, I believe, there is a good chance that it is setup correctly.
Sure, it makes sense to check the firewall issue.
It was the ports that were closed. Thanks a bunch. :)
I'm glad you solved it.