STOMP : Simple Text Oriented Messaging Protocol
Recently I come to know that if in your app the background operations are in Bulk, so it’s not wise to use standard method to get updates.
Suppose you crafted an app which deletes twitter direct messages of various authorised twitter users. So in this case we need strong background operations handler which without lagging makes our work done. Here Stomp actively take parts. Actually ActiveMQ is a Message Broker written in java that implements JMS (Java Message Service). Amongst other protocols, it supports Stomp, which we use to talk to it via PHP.
PHP Stomp Extension
Download and install the PHP Stomp extension: http://pecl.php.net/package/stomp
You can probably install this with: pear install stomp At the command line, run php -i and look that "Stomp" is enabled.
Example code :
<?php $queue = '/queue/foo'; $msg = 'bar'; /* connection */ try { $stomp = new Stomp('tcp://localhost:61613'); } catch(StompException $e) { die('Connection failed: ' . $e->getMessage()); } /* send a message to the queue 'foo' */ $stomp->send($queue, $msg); /* subscribe to messages from the queue 'foo' */ $stomp->subscribe($queue); /* read a frame */ $frame = $stomp->readFrame(); if ($frame->body === $msg) { var_dump($frame); /* acknowledge that the frame was received */ $stomp->ack($frame); } /* close connection */ unset($stomp); ?>
Hope it will help you for jump start for Stomp.










