['delete','create'],'message' => '队列名称为空'], [['passive','exclusive','auto_delete'],'default','value' => false,'on' => 'create'], ['durable','default','value' => true,'on' => 'create'], [['if_unused','if_empty','nowait'],'default','on' => 'delete'], ['ticket','default','value' => null,'on' => 'delete'], [['user','pass'],'required','on' => 'list','message' => '用户名和密码不能为空'] ]; } /** * @return mixed */ public function createQueue() { $connection = Connection::getInstance(); $channel = $connection->channel(); $queue = $channel->queue_declare($this->queue, $this->passive, $this->durable, $this->exclusive, $this->auto_delete); return isset($queue[0]) ? : null; } /** * @return mixed */ public function deleteQueue() { $connection = Connection::getInstance(); $channel = $connection->channel(); $res = $channel->queue_delete($this->queue,$this->if_unused,$this->if_empty,$this->nowait,$this->ticket); return $res; } /** * @return array */ public function listQueue() { $url = 'http://192.168.1.183:15672/api/queues'; $curl = new CUrl(); $curl->authorize = $this->user . ':' . $this->pass; $res = $curl->get($url); $res = json_decode($res,true); return array_column($res,'name'); } }