初步MQ 备注

This commit is contained in:
ASUS 2025-10-14 15:27:18 +08:00
parent d2a46c4738
commit d0588895b5
11 changed files with 75 additions and 11 deletions

View File

@ -65,7 +65,7 @@ class ApplySmsTemp extends Command
$callback = function ($msg) use ($queue){
$date_time = date('Y-m-d H:i:s');
$data = $msg->body;
Log::info('收到消息--->' . $data . '--->' . $date_time . "\n");
Log::info('MQ收到消息[申请新短信模版]--->' . $data . '--->' . $date_time . "\n");
// 发给队列
Redis::send('apply.sms.temp', $data);
$msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);

View File

@ -65,7 +65,7 @@ class BirthdayGiftSms extends Command
$callback = function ($msg) use ($queue){
$date_time = date('Y-m-d H:i:s');
$data = $msg->body;
Log::info('收到消息--->' . $data . '--->' . $date_time . "\n");
Log::info('MQ收到消息[生日有礼]--->' . $data . '--->' . $date_time . "\n");
// 发给队列
Redis::send('birthday.gift.sms', $data);
$msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);

View File

@ -18,8 +18,8 @@ use support\Log;
class RabbOrderPrint extends Command
{
protected static $defaultName = 'RabbOrderPrint';
protected static $defaultDescription = 'RabbOrderPrint';
protected static $defaultName = 'rabborderprint';
protected static $defaultDescription = 'rabborderprint';
/**
* @return void
@ -64,7 +64,7 @@ class RabbOrderPrint extends Command
$callback = function ($msg) use ($queue){
$date_time = date('Y-m-d H:i:s');
$data = $msg->body;
Log::info('收到消息--->' . $data . '--->' . $date_time . "\n");
Log::info('MQ收到消息[订单打印]--->' . $data . '--->' . $date_time . "\n");
// 如果是数字。则打印订单
$is_log = false;
$curl_error = '';

View File

@ -17,8 +17,8 @@ use support\Log;
class RabbProductUpdate extends Command
{
protected static $defaultName = 'RabbProductUpdate';
protected static $defaultDescription = 'RabbProductUpdate';
protected static $defaultName = 'rabbproductupdate';
protected static $defaultDescription = 'rabbproductupdate';
/**
* @return void
@ -61,8 +61,7 @@ class RabbProductUpdate extends Command
$callback = function ($msg) use ($queue){
$date_time = date('Y-m-d H:i:s');
$data = $msg->body;
print_r('收到商品更新消息--->' . $data . '--->' . $date_time . "\n");
Log::info('收到商品更新消息--->' . $data . '--->' . $date_time . "\n");
Log::info('MQ收到消息[商品更新]--->' . $data . '--->' . $date_time . "\n");
// 如果是数字。则打印订单
$is_log = false;
$curl_error = '';

View File

@ -65,7 +65,7 @@ class SendMarkSms extends Command
$callback = function ($msg) use ($queue){
$date_time = date('Y-m-d H:i:s');
$data = $msg->body;
Log::info('收到消息--->' . $data . '--->' . $date_time . "\n");
Log::info('MQ收到消息[发送营销短信]--->' . $data . '--->' . $date_time . "\n");
// 发给队列
Redis::send('send.mark.sms', $data);
$msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);

View File

@ -65,7 +65,7 @@ class SendWechatTemp extends Command
$callback = function ($msg) use ($queue){
$date_time = date('Y-m-d H:i:s');
$data = $msg->body;
Log::info('收到消息--->' . $data . '--->' . $date_time . "\n");
Log::info('MQ收到消息[发送微信模版消息]--->' . $data . '--->' . $date_time . "\n");
// 发给队列
Redis::send('send.wechat.temp', $data);
$msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);

View File

@ -18,5 +18,10 @@ class ApplySmsTemp implements Consumer
{
Log::info('消息队列【申请新短信模版】接收到消息' . $data);
}
}

View File

@ -17,5 +17,9 @@ class BirthdayGiftSms implements Consumer
public function consume($data)
{
Log::info('消息队列【生日有礼】接收到消息' . $data);
}
}

View File

@ -17,5 +17,10 @@ class SendMarkSms implements Consumer
public function consume($data)
{
Log::info('消息队列【发送营销短信】接收到消息' . $data);
}
}

View File

@ -17,5 +17,11 @@ class SendWechatTemp implements Consumer
public function consume($data)
{
Log::info('消息队列【发送微信模版消息】接收到消息' . $data);
}
}

45
start_webman_commands.php Normal file
View File

@ -0,0 +1,45 @@
<?php
/**
* 执行多个webman相关的nohup命令
*/
// 定义要执行的命令列表
//$commands = [
// 'nohup php webman applysmstemp &',
// 'nohup php webman birthdaygiftsms &',
// 'nohup php webman birthdaygiftsms &',
// 'nohup php webman rabborderprint &',
// 'nohup php webman rabbproductupdate &',
// 'nohup php webman sendmarksms &',
// 'nohup php webman sendwechattemp &',
//];
$commands = [
'php webman applysmstemp',
'php webman birthdaygiftsms',
'php webman birthdaygiftsms',
'php webman rabborderprint',
'php webman rabbproductupdate',
'php webman sendmarksms',
'php webman sendwechattemp',
];
echo "开始执行命令...\n";
// 遍历并执行每个命令
foreach ($commands as $index => $command) {
echo "执行第 " . ($index + 1) . " 条命令: {$command}\n";
// 执行命令
$output = [];
$returnVar = 0;
exec($command, $output, $returnVar);
// 检查命令执行结果
if ($returnVar === 0) {
echo "命令执行成功\n";
} else {
echo "命令执行失败,返回码: {$returnVar}\n";
echo "输出信息: " . implode("\n", $output) . "\n";
}
}
echo "所有命令已提交执行\n";