TestController.php 467 B

123456789101112131415161718192021
  1. <?php
  2. namespace client\controllers;
  3. use biz\message\services\InformAdminService;
  4. use common\components\util;
  5. use Yii;
  6. class TestController extends BaseController
  7. {
  8. public function actionRabbit()
  9. {
  10. InformAdminService::addInform(12358, 'goodsSold', ['price' => 20]);
  11. util::end();
  12. $producer = Yii::$app->rabbitmq->getProducer('producerCommon');
  13. $msg = serialize(['user_id' => rand(111, 999)]);
  14. $producer->publish($msg, 'exCommon', 'routeCommon');
  15. }
  16. }