CAMQP Extension ¶
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.
Changelog: ¶
- 1.1 Flags bitmask added, some bugs fixed
1.0 Initial release
Requirements ¶
- Yii 1.1.*
- AMQP PECL extension (http://pecl.php.net/package/amqp)
Installation ¶
- Unpack all files under your project 'component' folder
- Include your new extenion into your project main.php configuration file:
'components' => array(
'amqp' => array(
'class' => 'application.components.AMQP.CAMQP',
'host' => '127.0.0.1'
)
)
- Enjoy!
Usage ¶
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!
It depends on the amqp pecl extension
It seems to depend on the amqp pecl extension , try this:
pecl install amqp
It's not available under windows yet
The extension is not working
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 }
Support
how can i fix this issue?
AMQPQueue.php class not found error.
I am getting above error about class not found or fail to open AMQPQueue.php file
Please suggest where do i need to include AMQPQueue.php file
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.