浏览代码

消息持久化

shish 7 月之前
父节点
当前提交
c7dd5b642c

+ 2 - 2
app-ghs/controllers/CustomController.php

@@ -681,7 +681,7 @@ class CustomController extends BaseController
                 $producer = Yii::$app->rabbitmq->getProducer('customProducer');
                 $msg = serialize(['type' => 'add_custom', 'name' => $name, 'mobile' => $mobile, 'sjId' => $this->sjId,
                     'shopId' => $this->shop->id, 'sjName' => $this->sj->name, 'staffId' => $this->shopAdminId]);
-                $producer->publish($msg, 'customExchange', 'customRoute');
+                $producer->publish($msg, 'customExchange', 'customRoute',['delivery_mode' => 2, 'content_type' => 'application/octet-stream']);
             } catch (\Exception $e) {
                 $msg = $e->getMessage();
                 $remind = "供货商创建新客户,生产消息报错 {$name} {$mobile} {$this->sj->name} {$msg}";
@@ -730,7 +730,7 @@ class CustomController extends BaseController
         try {
             $producer = Yii::$app->rabbitmq->getProducer('customProducer');
             $msg = serialize(['type' => 'pull_custom_from_other_shop', 'toShopId' => $toShopId, 'fromShopId' => $fromShopId]);
-            $producer->publish($msg, 'customExchange', 'customRoute');
+            $producer->publish($msg, 'customExchange', 'customRoute',['delivery_mode' => 2, 'content_type' => 'application/octet-stream']);
         } catch (\Exception $e) {
             $msg = $e->getMessage();
             $remind = "供货商拉取其他门店客户,生产消息报错 {$toShopId} {$fromShopId} {$msg}";

+ 1 - 4
app-ghs/controllers/TestController.php

@@ -47,10 +47,7 @@ class TestController extends BaseController
     {
         $producer = Yii::$app->rabbitmq->getProducer('stockProducer');
         $msg = serialize(['type' => 'add', 'name' => 'shish']);
-        $producer->publish($msg, 'stockExchange', 'stockRoute',[
-            'delivery_mode' => 2,  // 2 表示持久化,1 表示非持久化
-            'content_type' => 'application/octet-stream'
-        ]);
+        $producer->publish($msg, 'stockExchange', 'stockRoute', ['delivery_mode' => 2, 'content_type' => 'application/octet-stream']);
     }
 
     public function actionFx()

+ 0 - 7
app-pt/controllers/WxOpenController.php

@@ -241,13 +241,6 @@ class WxOpenController extends PublicController
                 xhMerchantService::updateById($id, $wxData);
                 MerchantExtendClass::updateByCondition(['sjId' => $id], ['wxAppId' => $authorizeAppId, 'wxAuth' => 1]);
 
-                //还没有完成初始化先进行初始化
-                if (isset($sjWxInfo['init']) && $sjWxInfo['init'] == 0) {
-                    $data = ['sjId' => $id];
-                    $producer = Yii::$app->rabbitmq->getProducer('openShopInitProducer');
-                    $msg = serialize($data);
-                    $producer->publish($msg, 'openShopInitExchange', 'openShopInitRoute');
-                }
                 echo 'ok';
             }
         }

+ 1 - 5
biz-hd/message/classes/InformAdminClass.php

@@ -67,11 +67,7 @@ class InformAdminClass extends BaseClass
         $data = array_merge($data, $respond);
 
         self::consumeInformQueue($data);
-
-//        $producer = Yii::$app->rabbitmq->getProducer('informProducer');
-//        $msg = serialize($data);
-//        $producer->publish($msg, 'informExchange', 'informRoute');
-
+        return true;
     }
 
     //宝贝售出提醒 ssh 2020.5.31

+ 1 - 4
biz-mall/message/classes/InformAdminClass.php

@@ -68,10 +68,7 @@ class InformAdminClass extends BaseClass
 
         self::consumeInformQueue($data);
 
-//        $producer = Yii::$app->rabbitmq->getProducer('informProducer');
-//        $msg = serialize($data);
-//        $producer->publish($msg, 'informExchange', 'informRoute');
-
+        return true;
     }
 
     //宝贝售出提醒 ssh 2020.5.31

+ 1 - 1
biz/common/classes/GhsNotifyClass.php

@@ -15,7 +15,7 @@ class GhsNotifyClass extends BaseClass
         try {
             $producer = Yii::$app->rabbitmq->getProducer('notifyProducer');
             $msg = serialize(['type' => 'ghs_new_order_notify', 'orderId' => $orderId]);
-            $producer->publish($msg, 'notifyExchange', 'notifyRoute');
+            $producer->publish($msg, 'notifyExchange', 'notifyRoute',['delivery_mode' => 2, 'content_type' => 'application/octet-stream']);
         } catch (\Exception $e) {
             $msg = $e->getMessage();
             $remind = "供货商新订单通知,生产消息报错 {$orderId} {$msg}";

+ 2 - 2
biz/common/classes/HdNotifyClass.php

@@ -14,7 +14,7 @@ class HdNotifyClass extends BaseClass
         try {
             $producer = Yii::$app->rabbitmq->getProducer('notifyProducer');
             $msg = serialize(['type' => 'hd_new_order_notify', 'orderId' => $orderId]);
-            $producer->publish($msg, 'notifyExchange', 'notifyRoute');
+            $producer->publish($msg, 'notifyExchange', 'notifyRoute',['delivery_mode' => 2, 'content_type' => 'application/octet-stream']);
         } catch (\Exception $e) {
             $msg = $e->getMessage();
             $remind = "花店新订单通知,生产消息报错 {$orderId} {$msg}";
@@ -27,7 +27,7 @@ class HdNotifyClass extends BaseClass
         try {
             $producer = Yii::$app->rabbitmq->getProducer('notifyProducer');
             $msg = serialize(['type' => 'hd_new_cg_notify', 'cgId' => $cgId]);
-            $producer->publish($msg, 'notifyExchange', 'notifyRoute');
+            $producer->publish($msg, 'notifyExchange', 'notifyRoute',['delivery_mode' => 2, 'content_type' => 'application/octet-stream']);
         } catch (\Exception $e) {
             $msg = $e->getMessage();
             $remind = "花店新采购单通知,生产消息报错 {$cgId} {$msg}";

+ 4 - 0
common/config/rabbitMQ.php

@@ -20,6 +20,7 @@ $rabbitMQ = [
         [
             'name' => 'customExchange',
             'type' => 'direct',
+            'durable' => true,
         ],
         [
             'name' => 'stockExchange',
@@ -29,6 +30,7 @@ $rabbitMQ = [
         [
             'name' => 'notifyExchange',
             'type' => 'direct',
+            'durable' => true,
         ]
     ],
 
@@ -39,6 +41,7 @@ $rabbitMQ = [
         [
             'name' => 'customQueue',
             'passive' => false,
+            'durable' => true,
         ],
         [
             'name' => 'stockQueue',
@@ -48,6 +51,7 @@ $rabbitMQ = [
         [
             'name' => 'notifyQueue',
             'passive' => false,
+            'durable' => true,
         ],
     ],