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

NuttySquirrel
NuttySquirrel used Ask the Experts™
on
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.


Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Awarded 2011
Awarded 2011
Commented:


As you experience the problem at connection moment and as it works with local host,
maybe you want to play with some parameters of timeoutout, reconnectDelay, etc.,
look at these examples
failover:(tcp://localhost:61616,tcp://remotehost:61616)?initialReconnectDelay=100

failover:(tcp://primary:61616)?timeout=3000

(though you may rather want to increase timeout)
on this site:


http://activemq.apache.org/failover-transport-reference.html

Also check that you access remotehost with port
from the command line

Author

Commented:
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.
Awarded 2011
Awarded 2011

Commented:
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.

Author

Commented:
It was the ports that were closed. Thanks a bunch. :)
Awarded 2011
Awarded 2011

Commented:
Great!
I'm glad you solved it.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial