发布时间:2015-05-27 19:22:20作者:知识屋
connect();$channel = new AMQPChannel($connect);$exchange = new AMQPExchange($channel);$exchange->setName('exchange');$exchange->setType(AMQP_EX_TYPE_DIRECT);$exchange->declare();$queue = new AMQPQueue($channel);$queue->setName('logs');$queue->declare();$queue->bind('exchange', 'logs');while (true) { $queue->consume('callback');}$connection->close();function callback($envelope, $queue) { var_dump($envelope->getBody()); $queue->nack($envelope->getDeliveryTag());}
connect();$channel = new AMQPChannel($connect);$exchange = new AMQPExchange($channel);$exchange->setName('exchange');$exchange->setType(AMQP_EX_TYPE_DIRECT);$exchange->declare();$exchange->publish('direct type test','logs');var_dump("Send Message OK");$connect->disconnect();
connect();$channel = new AMQPChannel($connect);$exchange = new AMQPExchange($channel);$exchange->setName('exchange');$exchange->setType(AMQP_EX_TYPE_DIRECT);$exchange->declare();$queue = new AMQPQueue($channel);$queue->setName('logs');@$queue->declare();$queue->bind('exchange', 'logs');while (true) { $queue->consume('callback');}$connection->close();function callback($envelope, $queue) { var_dump($envelope->getBody()); $queue->nack($envelope->getDeliveryTag());}
connect();$channel = new AMQPChannel($connect);$exchange = new AMQPExchange($channel);$exchange->setName('exchange');$exchange->setType(AMQP_EX_TYPE_DIRECT);$exchange->declare();for ($index = 1; $index < 5; $index++) { $exchange->publish($index,'logs'); var_dump("Send:$index");}$exchange->delete();$connect->disconnect();
for ($index = 1; $index < 50; $index++) { $exchange->publish($index,'logs'); var_dump("Send:$index");}
function callback($envelope, $queue) { var_dump($envelope->getBody()); sleep(3); $queue->nack($envelope->getDeliveryTag());}
$channel = new AMQPChannel($connect);改成如下
$channel = new AMQPChannel($connect);$channel->setPrefetchCount(1);
如何对PHP文件进行加密方法 PHP实现加密的几种方式介绍
php生成圆角图片的方法 电脑中php怎么生成圆角图片教程
用PHP构建一个留言本方法步骤 php怎么实现留言板功能
php中三元运算符用法 php中的三元运算符使用说明
php文件如何怎么打开方式介绍 php文件用什么打开方法
PHP怎么插入数据库方法步骤 php编程怎么导入数据库教程
如何安装PHPstorm并配置方法教程 phpstorm安装后要进行哪些配置
PHP 获取远程文件大小的3种解决方法 如何用PHP获取远程大文件的大小
20个实用PHP实例代码 php接口开发实例代码详细介绍
如何架设PHP服务器方法步骤 怎么搭建php服务器简单教程