1. laravel消息订阅
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Redis;
class TestMtQuote extends Command
{
protected $signature = 'quote:real';
protected $description = 'mt_server test';
public function __construct()
{
parent::__construct();
}
public function handle()
{
$that = $this;
try{
$redis = Redis::connection('mt_server');
Redis::psubscribe(['PUBQUOTE:REAL'], function($message) use($that){
$data = json_decode($message,1);
$that->test($data);
},'mt_server');
}catch (\Exception $e){
dump($e->getLine(),$e->getFile(),$e->getMessage());
}
}
public function test($arr=[]){
dump($arr);
}
}