happyr / stomp-bundle
该包已被弃用且不再维护。未建议替代包。
Symfony2 Bundle,用于封装fusesource/stomp-php库
0.1.0
2013-11-09 10:24 UTC
Requires
- php: >=5.3.2
- fusesource/stomp-php: 2.*
- symfony/framework-bundle: 2.*
This package is auto-updated.
Last update: 2022-02-01 12:28:13 UTC
README
一个用于集成Fusesource Stomp PHP库的Symfony2 bundle。
安装
-
使用composer安装
php composer.phar require happyr/stomp-bundle
-
启用bundle
// app/AppKernel.php public function registerBundles() { $bundles = array( // ... new HappyR\StompBundle\HappyRStompBundle(), ); }
使用服务
//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();
完整的默认配置
happy_r_stomp: borker_uri: tcp://localhost:61613 client_id: ~
更多文档
由于此bundle只是fusesource/stomp-php库的封装,您应该查看他们的配置。