activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Samplonius <...@samplonius.org>
Subject Re: Java stomp subscriber, StompConnect?
Date Wed, 27 Jun 2007 06:06:21 GMT

  What you are doing is fairly unclear.  It seems like you are trying to use the StompConnect
JMS to Stomp bridge as a JMS client.  It is not a JMS client though.  StompConnect is messaging
middle-ware.  It presents a Stomp protocol front-end, and translate to some other vendors
JMS API.  Its main use is to still in front of another message broker's JMS API, and convert
Stomp to JMS.

  If you want to write a messaging client in Java, you should probably use the JMS API.  Take
a look at:

http://java.sun.com/products/jms/tutorial/

And if you are using Java, you might as well use OpenWire too.  The JMS API is pretty rich,
in comparison to Stomp, so you can actually get status like queue size too.

  And you should probably check the Web Console or JConsole to see if the messages are actually
in the queue you think they should be.  Perhaps the 

  And a OpenWire consumer and a Stomp producer should be no problem.  But you should take
care on your message encoding.



----- "Ianjl" <ijl708@gmail.com> wrote:
> 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.


Mime
View raw message