1 Star 0 Fork 0

zhzhouq9/rabbitmq-tutorials

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
new_task.php 818 Bytes
一键复制 编辑 原始数据 按行查看 历史
<?php
//Establish connection to AMQP
$connection = new AMQPConnection();
$connection->setHost('127.0.0.1');
$connection->setLogin('guest');
$connection->setPassword('guest');
$connection->connect();
//Create and declare channel
$channel = new AMQPChannel($connection);
$channel->setPrefetchCount(1);
$routing_key = 'task_queue';
try{
$queue = new AMQPQueue($channel);
$queue->setName($routing_key);
$queue->setFlags(AMQP_DURABLE);
$queue->declareQueue();
}catch(Exception $ex){
print_r($ex);
}
//Read from stdin
$message = implode(' ', array_slice($argv,1));
if(empty($message))
$message = "Hello World!";
$exchange = new AMQPExchange($channel);
$exchange->publish($message, $routing_key, AMQP_NOPARAM, array('delivery_mode' => 2));
echo " [x] Sent {$message}", PHP_EOL;
$connection->disconnect();
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/zhzhouq9/rabbitmq-tutorials.git
git@gitee.com:zhzhouq9/rabbitmq-tutorials.git
zhzhouq9
rabbitmq-tutorials
rabbitmq-tutorials
master

搜索帮助