activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ianjl <>
Subject Java stomp subscriber, StompConnect?
Date Tue, 26 Jun 2007 20:50:04 GMT

The Goal
I need a Java subscriber client which runs locally.  This client needs to
connect to an ActiveMQ message broker and read messages from
stomp://WKS-W0106843:61613 (this is the local machine also) the queue is

The Situation
I have a perl script that parses files on the server, packages the
information into xml messages, and passes them to the broker running on my
local machine.

I have a perl client that can read the messages so I know that the messages
reach the AMQ broker.  Here is the code for the perl subscriber:

while (1) {
      my $stomp2 = Net::Stomp->new( { hostname => 'localhost', port =>
'61613' } );
      $stomp2->connect( { login => '', passcode => '' } );
          {   destination                 => '/queue/pvcrawlerXML',
              'ack'                          => 'client',
              'activemq.prefetchSize' => 1
        my $frame = $stomp2->receive_frame;
        my $str =  "I have consumed a message: " .$frame->body; 
	print "$str\r\n";
        $stomp2->ack( { frame => $frame } );

I require the same result except in Java.  My attempts so far have not
archived anything except confusion.
I have played with the and build.xml, changing the

	<property name="url" value="tcp://localhost:61616" />
	<property name="subject" value="/queue/FOO.BAR" />
	<property name="url" value="stomp://localhost:61613" />
	<property name="subject" value="/queue/pvcrawlerXML" />

The above change doesn't cause any exceptions just hangs
at the 'connection.start();' call.  I assume that this is because
ConsumerTool does not support stomp.
I then started playing with, see below:

public class ActiveMQStompConnect {

	public static void main(String[] args) {
        try {
            StompConnect connect = new StompConnect();
            String url = "stomp://localhost:61613"; <-- only change here.
            if (args.length > 0) {
                url = args[0];
        catch (Exception e) {
            System.out.println("Caught: " + e);

If I run the above when my broker is running i get this error from
Failed to bind to server socket: tcp://localhost:61613 due to: Address already in use: JVM_Bind

How do I get at my messages from queue pvcrawlerXML, on the AMQ broker
listening to stomp://WKS-W0106843:61613 using a Java client? The perl
subscriber is not an option here.

Thank you for any help,

View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message