DoubleGIS company presents Yii extensions for MQ-Servers like RabbitMQ, ApacheMQ or other servers which support AMQP protocol.
The 'CAMQP' is a Yii Framework Plugin that provides a Gateway for MQ-Server interface. Contains all methods to add/edit/delete/read messages/queues/exchanges on the broker.
Allow to work in 'Fake' mode to avoid direct connection to the broker.
'components' => array( 'amqp' => array( 'class' => 'application.components.AMQP.CAMQP', 'host' => '127.0.0.1' ) )
To write a message into the MQ-Exchange:
Yii::app()->amqp->exchange('topic')->publish('some message','some.route');
To read a message from MQ-Queue:
Yii::app()->amqp->queue('some_listener')->get();
To Create an Exchange from the Script:
$ex = Yii::app()->amqp->declareExchange('my_new_exchange'); ... // now we can use created exchange $ex->publish('message1', 'some.route'); $ex->publish('message2', 'some.route'); $ex->publish('message3', 'some.route'); ... $ex->publish('messageN', 'some.route');
To Create a Queue from the Script:
$queue = Yii::app()->amqp->declareQueue('my_new_queue'); ... // now we can use created queue while ($message = $queue->get()) { // reading all messages ... }
Bind a Queue to an Exchange:
$queue = Yii::app()->amqp->queue('my_new_queue'); $queue->bind('my_new_exchange'); ... $ex = Yii::app()->amqp->queue('my_new_exchange'); $ex->publish('Hello World!', 'routie'); ... echo $queue->get(); // Hello World! /* OR */ $queue = Yii::app()->amqp->bindQueueToExchange('my_new_queue', 'my_new_exchange'); ... echo $queue->get(); // Hello World!
Total 6 comments
Is this extension being actively supported ?
I'd be happy to help if the author is willing
I've tried to use it my project, however it does not working properly:
AMQPQueue::declare() expects exactly 0 parameters, 2 given
/var/www/t.depo.fm/protected/components/AMQP/CAMQP.php(129)
117 $ex = new CAMQPExchange($this->getChannel()); 118 return $ex->declare($name, $type, $flags); 119 } 120 121 /** 122 * @brief Declares a new Queue on the broker 123 * @param $name 124 * @param $flags 125 */ 126 public function declareQueue($name, $flags = NULL) 127 { 128 $queue = new CAMQPQueue($this->getChannel()); 129 return $queue->declare($name, $flags); 130 }
The "C" prefix is reserved for Yii core classes. Please consider using other prefix (like DG in your other extensions)
It seems to depend on the amqp pecl extension , try this: pecl install amqp It's not available under windows yet
Yes
Got an error when I try to use it
I guess I need to have this class?
http://www.php.net/manual/en/class.amqpqueue.php
Leave a comment
Please login to leave your comment.