<?php

namespace app\index\controller;

use app\common\util\QueueHelp\Queue;
use app\common\util\QueueHelp\TestMq;

class Test extends Base
{

	private $queue_name;//队列名
    public function __construct() 
    {
		parent::__construct();
		$this->queue_name 	= 'TestMq';
    }

	//测试队列放入与拿出
	public function test_queue_push_pull(){
		$config['db'] 			= 1;//队列数据库
		$Queue                  = new Queue($config);
		$TestMq                	= new TestMq;
		//MQ的字段可以自己设,需要在mq文件中对应修改
		$TestMq->test_id        = 123;
		$TestMq->test_name    	= 'tester';
		$TestMq->test_type    	= 0;
		$result 	= $Queue->push($this->queue_name, $TestMq);
		//推送队列结果
		var_dump($result);
		
		$res 	= $Queue->pull($this->queue_name);
		//从队列拿取数据结果
		var_dump($res);		
	}	
	
}