lin 6 years ago
parent
commit
f26486e25d

+ 6 - 7
backend/controllers/SubscribeController.php

@@ -62,13 +62,13 @@ class SubscribeController extends BaseController
      */
     public function actionDelete()
     {
-        $model = new TopicForm();
-        $model->setScenario('delete_topic');
-        $model->load(['TopicForm' => Yii::$app->request->post()]);
+        $model = new SubscribeForm();
+        $model->setScenario('delete_subscribe');
+        $model->load(['SubscribeForm' => Yii::$app->request->post()]);
 
         $data = [];
         if ($model->validate()) {
-            $data = $model->deleteTopic();
+            $data = $model->Unsubscribe();
         } else {
             $model->handleError();
         }
@@ -86,9 +86,8 @@ class SubscribeController extends BaseController
      */
     public function actionList()
     {
-        $model = new TopicForm();
-        $data = $model->getQueueList();
-
+        $model = new SubscribeForm();
+        $data = $model->getSubscribeList();
         return [
             'code' => 200,
             'message' => Yii::t('error', 200),

+ 1 - 1
backend/controllers/TopicController.php

@@ -86,7 +86,7 @@ class TopicController extends BaseController
     public function actionList()
     {
         $model = new TopicForm();
-        $data = $model->getQueueList();
+        $data = $model->getTopicList();
 
         return [
             'code' => 200,

+ 12 - 16
backend/forms/SubscribeForm.php

@@ -81,7 +81,7 @@ class SubscribeForm extends BaseForm
 		try {
 			$connect = $this->getConnect();
 			$channel = $connect->channel();
-			$channel->exchange_delete($this->name, false, false );
+			$channel->queue_unbind($this->name, false, false );
 			return [
 				'name' => $this->name,
 				'result' => '删除成功'
@@ -96,10 +96,10 @@ class SubscribeForm extends BaseForm
 	 * [获取消息列表]
 	 * @author: libingke
 	 */
-	public function getQueueList()
+	public function getSubscribeList()
 	{
 		$authStr = Yii::$app->Amqp->user . ':' . Yii::$app->Amqp->pass;
-		$url = Yii::$app->Amqp->host . ':' . Yii::$app->Amqp->api_port . "/api/queues";
+		$url = Yii::$app->Amqp->host . ':' . Yii::$app->Amqp->api_port . "/api/bindings";
 
 		$curl = new Curl();
 		$curl->setOption(CURLOPT_USERPWD, $authStr);
@@ -115,19 +115,15 @@ class SubscribeForm extends BaseForm
 
 		$rows = [];
 		foreach ($result as $k => $v) {
-			//$name = $v['name'];
-			$name = $v['name'];
-			$rows[$name]['name'] 			= $name;
-			$rows[$name]['messages_count']	= $v['messages'];
-			$rows[$name]['message_bytes']	= $v['message_bytes'];
-			$rows[$name]['messages_ready']	= $v['messages_ready'];
-			//$rows[$name]['message_stats']	= $v['message_stats'];
-			$rows[$name]['consumers_count']	= $v['consumers'];
-			$rows[$name]['auto_delete']		= $v['auto_delete'];
-			$rows[$name]['durable']			= $v['durable'];
-			//$rows[$name]['arguments']		= $v['arguments'];
-			$rows[$name]['state']			= $v['state'];
-			$rows[$name]['idle_since']		= $v['idle_since'];
+		    //destination  exchange
+			$name = $v['destination'];
+			$rows[$name]['destination'] 			= $name;
+			$rows[$name]['source']	= $v['source'];
+            $rows[$name]['topicName']	= $v['source'];
+			$rows[$name]['destination_type']	= $v['destination_type'];
+			$rows[$name]['routing_key']	= $v['routing_key'];
+			$rows[$name]['arguments']	= $v['arguments'];
+			$rows[$name]['properties_key']	= $v['properties_key'];
 		}
 		unset($result);
 

+ 43 - 40
backend/forms/TopicForm.php

@@ -67,45 +67,48 @@ class TopicForm extends BaseForm
 		}
 	}
 
-	/**
-	 * [获取消息列表]
-	 * @author: libingke
-	 */
-	public function getQueueList()
-	{
-		$authStr = Yii::$app->Amqp->user . ':' . Yii::$app->Amqp->pass;
-		$url = Yii::$app->Amqp->host . ':' . Yii::$app->Amqp->api_port . "/api/queues";
-
-		$curl = new Curl();
-		$curl->setOption(CURLOPT_USERPWD, $authStr);
-		$result = json_decode($curl->get($url), true);
-		if ($curl->responseCode != 200)
-			throw new Exception(1002);
-
-		if ($curl->errorText)
-			throw new Exception(1002, $curl->errorText);
-
-		if (isset($result['error']) && is_string($result['error']))
-			throw new Exception(1002, $result['error']);
-
-		$rows = [];
-		foreach ($result as $k => $v) {
-			//$name = $v['name'];
-			$name = $v['name'];
-			$rows[$name]['name'] 			= $name;
-			$rows[$name]['messages_count']	= $v['messages'];
-			$rows[$name]['message_bytes']	= $v['message_bytes'];
-			$rows[$name]['messages_ready']	= $v['messages_ready'];
-			//$rows[$name]['message_stats']	= $v['message_stats'];
-			$rows[$name]['consumers_count']	= $v['consumers'];
-			$rows[$name]['auto_delete']		= $v['auto_delete'];
-			$rows[$name]['durable']			= $v['durable'];
-			//$rows[$name]['arguments']		= $v['arguments'];
-			$rows[$name]['state']			= $v['state'];
-			$rows[$name]['idle_since']		= $v['idle_since'];
-		}
-		unset($result);
 
-		return ['count' => count($rows), 'rows' => $rows];
-	}
+
+    /**
+     * [获取消息列表]
+     * @author: libingke
+     */
+    public function getTopicList()
+    {
+        $authStr = Yii::$app->Amqp->user . ':' . Yii::$app->Amqp->pass;
+        $url = Yii::$app->Amqp->host . ':' . Yii::$app->Amqp->api_port . "/api/exchanges";
+
+        $curl = new Curl();
+        $curl->setOption(CURLOPT_USERPWD, $authStr);
+        $result = json_decode($curl->get($url), true);
+
+
+        if ($curl->responseCode != 200)
+            throw new Exception(1002);
+
+        if ($curl->errorText)
+            throw new Exception(1002, $curl->errorText);
+
+        if (isset($result['error']) && is_string($result['error']))
+            throw new Exception(1002, $result['error']);
+
+        $rows = [];
+        foreach ($result as $k => $v) {
+            if($v['type'] = 'topic'){
+                $name = $v['name'];
+                $rows[$name]['name'] 			= $name;
+                $rows[$name]['auto_delete']		= $v['auto_delete'];
+                $rows[$name]['durable']			= $v['durable'];
+                $rows[$name]['arguments']		= $v['arguments'];
+                $rows[$name]['type']			= $v['type'];
+                $rows[$name]['vhost']		= $v['vhost'];
+            }
+        }
+        unset($result);
+
+        return ['count' => count($rows), 'rows' => $rows];
+    }
+
+
+
 }

+ 2 - 2
common/config/main.php

@@ -25,8 +25,8 @@ return [
             'class' => '\components\components\messageQueue\MessageInterface',
             'key' => 'QkwzrML50o1KIK5bI-HbkVBcTSA_Ehdh',
             'protocol' => 'http',
-//            'host' => '120.78.153.45'
-            'host' => 'ki.logsystemadmin.airent.test.com'
+           'host' => '120.78.153.45'
+            //           'host' => 'ki.logsystemadmin.airent.test.com'
         ],
 
         'cache' => [