symfony-bundle stomp-bundle
A Symfony2 Bundle to wrap the fusesource/stomp-php library
happyr/stomp-bundle
A Symfony2 Bundle to wrap the fusesource/stomp-php library
- Tuesday, June 9, 2015
- by Nyholm
- Repository
- 2 Watchers
- 0 Stars
- 914 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 2 Versions
- 11 % Grown
HappyR StompBundle
A Symfony2 bundle that integrates the Fusesource Stomp PHP library., (*1)
Installation
-
Install with composer:, (*2)
php composer.phar require happyr/stomp-bundle
-
Enable the bundle:, (*3)
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new HappyR\StompBundle\HappyRStompBundle(),
);
}
Using the service
//get the connection
$con = $this->container->get('happyr.stomp.broker');
// send a message to the queue
$con->send("/queue/test", "test");
echo "Sent message with body 'test'\n";
// subscribe to the queue
$con->subscribe("/queue/test");
// receive a message from the queue
$msg = $con->readFrame();
// do what you want with the message
if ( $msg != null) {
echo "Received message with body '$msg->body'\n";
// mark the message as received in the queue
$con->ack($msg);
} else {
echo "Failed to receive a message\n";
}
// disconnect
$con->disconnect();
Full Default Configuration
happy_r_stomp:
borker_uri: tcp://localhost:61613
client_id: ~
More documentation
Since this bundle is just a wrapper for the fusesource/stomp-php library
you should checkout their configuration., (*4)