On Fri, Apr 2, 2010 at 5:55 AM, sravuri <ravurisu...@gmail.com> wrote: > > I am using activemq to connect my Java based system with PHP based system. > Here Java based system acts as producer and PHP system is the consumer of > the messages( I am using STOMP prootocal here ). > > In case Java Program sends 10 messsages, my PHP client is able to recieve > only 5 messages. Every alternative message is being lost. To give some Idea > of what I am doing, I am pasting my code(php) here. > > ################################ > > <?php > require_once 'Stomp.php'; > > $c = new StompConnection("localhost"); > $result = $c->connect("hiram", "test"); > print_r($result); > > $c->subscribe("/queue/TOOL.DEFAULT"); > $i = 1; > > while($i <= 10) > { > $frame = $c->readFrame(); > echo "test\n"; > > if ( $frame != null) > { > echo $frame->body; //process your message > echo "\n"; > } > } > $c->disconnect(); > ?> > ################################################## > > I have not called ack method here, as stomp.php I downloaded does not have > ack() method. Please suggest me the way out.
Below is a consumer example I just hacked together quickly. I tested it with ActiveMQ 5.3.0 and I used the stompcli from Fusesource (http://stomp.fusesource.org/): <? require_once('Stomp.php'); $stomp = new Stomp("tcp://localhost:61613"); $stomp->connect('system', 'manager'); $stomp->subscribe("/queue/TEST.FOO"); for ($i=0; $i < 2000; ++$i) { $frame = $stomp->readFrame(); echo "message.$frame-body\n"; $stomp->ack($frame); } $stomp->disconnect(); ?> 1) Save the above code into a file named consumer.php. 2) Start up ActiveMQ with the following transport connector in the conf/activemq.xml: <transportConnector name="stomp" uri="stomp://0.0.0.0:61613"/> 3) Start up the consumer by running 'php consumer.php' from the command line. 4) Send messages to the TEST.FOO queue using the examples that are part of ActiveMQ (http://activemq.apache.org/examples.html) by running 'ant producer'. The consumer will print out all 2000 messages to the command line and disconnect from ActiveMQ. Bruce -- perl -e 'print unpack("u30","D0G)u8...@4vyy9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*" );' ActiveMQ in Action: http://bit.ly/2je6cQ Blog: http://bruceblog.org/ Twitter: http://twitter.com/brucesnyder