1. Go to this page and download the library: Download qingmutec/monitor library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
qingmutec / monitor example snippets
/**
* @var \qmmonitor\command\Command
*/
private $command = null;
/**
* 配置信息
* @var array
*/
private $config = [];
public function __construct()
{
$this->command = new Command(env('app.app_name'));//传入当前项目名称,,会被当作进程标识
$this->config = config('queue');
}
/**
* 测试执行函数
* @return array
*/
public function run()
{
//启动
$this->command->start($this->config);
}
/**
* 重启队列
*/
public function restart()
{
$this->command->restart($this->config);
}
/**
* 结束队列
*/
public function stop()
{
$this->command->stop($this->config);
}
/**
* 结束队列
*/
public function reload()
{
$this->command->reload($this->config);
}
/**
* 获取队列运行状态
*/
public function list()
{
$list = $this->command->list();
$outputStr = '';
foreach ($list as $item) {
$outputStr .= $item . "\r\n";
}
exit(Color::blue($outputStr));
}
public function put()
{
try {
$queueComponent = new QueueComponent();
$queueComponent->setExchange('direct_goods_exchange')
->setQueue('direct_goods_test_queue')
->setProducerConfirm(true)
->setRouteKey('goods_test');
//或者使用RabbitMqQueueArguments对象设置属性后传入第二个参数中
$queueComponent->put('我是一个测试消息', null, $this->config);
} catch (\Throwable $exception) {
var_dump($exception->getMessage());
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.