rabb
This commit is contained in:
parent
60b727a0b6
commit
190b0323db
|
|
@ -87,6 +87,10 @@ class ApplySmsTemp extends Command
|
||||||
}else {
|
}else {
|
||||||
Log::info('MQ收到消息[申请新短信模版/营销短信发送/微信模版消息]格式错误');
|
Log::info('MQ收到消息[申请新短信模版/营销短信发送/微信模版消息]格式错误');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
|
$msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
|
||||||
};
|
};
|
||||||
$rabbit_channel->basic_consume($queue, '', false, false, false, false, $callback);
|
$rabbit_channel->basic_consume($queue, '', false, false, false, false, $callback);
|
||||||
|
|
|
||||||
|
|
@ -70,8 +70,4 @@ return [
|
||||||
'QuerySmsStatus' => [
|
'QuerySmsStatus' => [
|
||||||
'handler' => MessagePushTask::class
|
'handler' => MessagePushTask::class
|
||||||
],
|
],
|
||||||
// rabbitmq 消费者
|
|
||||||
'RabbitmqConsum' => [
|
|
||||||
'handler' => RabbConsumApplySmsTemp::class
|
|
||||||
]
|
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Bunny\Channel;
|
||||||
|
use Bunny\Message;
|
||||||
|
use Workerman\Worker;
|
||||||
|
use Workerman\RabbitMQ\Client;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/vendor/autoload.php';
|
||||||
|
|
||||||
|
$worker = new Worker();
|
||||||
|
$worker->eventLoop = \Workerman\Events\Fiber::class;
|
||||||
|
|
||||||
|
$worker->onWorkerStart = function() {
|
||||||
|
// Create RabbitMQ Client
|
||||||
|
$client = Client::factory([
|
||||||
|
'host' => '127.0.0.1',
|
||||||
|
'port' => 5672,
|
||||||
|
'user' => 'guest',
|
||||||
|
'password' => 'guest',
|
||||||
|
'vhost' => '/',
|
||||||
|
'heartbeat' => 60,
|
||||||
|
'heartbeat_callback' => function () {
|
||||||
|
echo " [-] coroutine-consumer-heartbeat\n";
|
||||||
|
},
|
||||||
|
'interval' => [100, 300]
|
||||||
|
])->connect();
|
||||||
|
$channel = $client->channel();
|
||||||
|
$channel->queueDeclare('hello-coroutine');
|
||||||
|
// Consumer
|
||||||
|
$channel->consume(function (Message $message, Channel $channel, \Bunny\AbstractClient $client) {
|
||||||
|
echo " [>] Received ", $message->content, "\n";
|
||||||
|
},
|
||||||
|
'hello-coroutine',
|
||||||
|
'',
|
||||||
|
false,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
$client->run();
|
||||||
|
echo ' [*] Waiting for messages. To exit press CTRL+C', "\n";
|
||||||
|
// Producer
|
||||||
|
\Workerman\Timer::add($interval = 5 , function () use ($channel) {
|
||||||
|
$channel->publish($message = 'Hello World By Self Timer. ' . time(), [], '', 'hello-coroutine');
|
||||||
|
echo " [<] Sent $message\n";
|
||||||
|
});
|
||||||
|
echo " [!] Producer timer created, interval: $interval s.\n";
|
||||||
|
};
|
||||||
|
Worker::runAll();
|
||||||
Loading…
Reference in New Issue