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
pvcrawlerXML.

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 => '' } );
      $stomp2->subscribe(
          {   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 } );
        $stomp2->disconnect;
      }


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


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


The above change doesn't cause any exceptions ConsumerTool.java just hangs
at the 'connection.start();' call.  I assume that this is because
ConsumerTool does not support stomp.
I then started playing with ActiveMQStompConnect.java, 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];
            }
            connect.setConnectionFactory(new
ActiveMQConnectionFactory(url));
            connect.start();
            connect.join();
        }
        catch (Exception e) {
            System.out.println("Caught: " + e);
            e.printStackTrace();
        }
    }
}

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

Conclusion
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,

Ian
-- 
View this message in context: 
http://www.nabble.com/Java-stomp-subscriber%2C-StompConnect--tf3984709s2354.html#a11313547
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to