diff --git a/scripts/applysmstemp.php b/scripts/applysmstemp.php new file mode 100644 index 0000000..af936a0 --- /dev/null +++ b/scripts/applysmstemp.php @@ -0,0 +1,63 @@ +channel(); + $rabbit_channel->queue_declare($queue, false, true, false, false, false, [ +// 'x-message-ttl' => ['I', 180000] + ]); + + $callback = function ($msg) use ($queue){ + $data = $msg->body; + Log::info('MQ收到消息[申请新短信模版/营销短信发送/微信模版消息]--->' . $data . "\n"); + $arr = explode(',', $data); + if(isset($arr[2])) { + $type = $arr[2]; + if($type == 'applySmsTemp') { + // 发给队列 短信模版审核 + $a = Redis::send('apply.sms.temp', $data); + Log::info('消息队列投递结果----》' . $a); + }elseif ($type == 'sendMarkSms') { + // 发给队列 营销短信发送 + Redis::send('send.mark.sms', $data); + }elseif ($type == 'sendWechatTemp') { + // 发给队列 发送微信模版消息 + Redis::send('send.wechat.temp', $data); + } + }else { + Log::info('MQ收到消息[申请新短信模版/营销短信发送/微信模版消息]格式错误'); + } + $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']); + }; + $rabbit_channel->basic_consume($queue, '', false, false, false, false, $callback); + while ($rabbit_channel->is_consuming()) { + $rabbit_channel->wait(); + } + $rabbit_channel->close(); + $connection->close();