troubleshooting Question

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

Avatar of NuttySquirrel
NuttySquirrel asked on
JavaWeb DevelopmentWCF
5 Comments1 Solution1081 ViewsLast Modified:
Hi,
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");
        connection.start();
        System.out.println("Connection established");
    
        Session session = connection.createSession(false,
            Session.AUTO_ACKNOWLEDGE);

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

        connection.close();

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
codeconnection.start()]

Open in new window

line.

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.


ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros