|
|
@@ -1,215 +0,0 @@
|
|
|
-<?php
|
|
|
-/**
|
|
|
- * rabbitmq的配置
|
|
|
- */
|
|
|
-$rabbitMQ = [
|
|
|
- /*'on before_consume' => function ($event) {
|
|
|
- if (isset(\Yii::$app->db)) {
|
|
|
- $db = \Yii::$app->db;
|
|
|
- if ($db->getIsActive()) {
|
|
|
- $db->close();
|
|
|
- }
|
|
|
- $db->open();
|
|
|
- }
|
|
|
- },
|
|
|
- 'logger' => [
|
|
|
- 'enable' => true,
|
|
|
- 'category' => 'amqp',
|
|
|
- 'print_console' => true,
|
|
|
- ],*/
|
|
|
- 'class' => 'mikemadisonweb\rabbitmq\Configuration',
|
|
|
- 'connections' => [
|
|
|
- [
|
|
|
- 'host' => getenv('RABBIT_MQ_HOST'),
|
|
|
- 'port' => getenv('RABBIT_MQ_PORT'),
|
|
|
- 'user' => 'guest',
|
|
|
- 'password' => 'guest',
|
|
|
- 'vhost' => '/', //虚拟主机
|
|
|
- ]
|
|
|
- ],
|
|
|
-
|
|
|
- /**
|
|
|
- * 交换器
|
|
|
- * 交换类型(type):direct、topic、headers、fanout
|
|
|
- * 列出交换器: rabbitmqctl list_exchanges
|
|
|
- */
|
|
|
- 'exchanges' => [
|
|
|
- [
|
|
|
- 'name' => 'commonExchange',
|
|
|
- 'type' => 'direct'
|
|
|
- ],
|
|
|
- [
|
|
|
- 'name' => 'informExchange',
|
|
|
- 'type' => 'direct'
|
|
|
- ],
|
|
|
- [
|
|
|
- 'name' => 'openShopInitExchange',
|
|
|
- 'type' => 'direct'
|
|
|
- ],
|
|
|
- /*
|
|
|
- [
|
|
|
- 'name' => 'topic_ex_1',
|
|
|
- 'type' => 'topic', // topic
|
|
|
- 'passive' => false,
|
|
|
- 'durable' => true,
|
|
|
- 'auto_delete' => false,
|
|
|
- 'internal' => false,
|
|
|
- 'nowait' => false,
|
|
|
- 'arguments' => null,
|
|
|
- 'ticket' => null,
|
|
|
- 'declare' => true,
|
|
|
- ],
|
|
|
- */
|
|
|
- ],
|
|
|
-
|
|
|
- /**
|
|
|
- * 队列
|
|
|
- */
|
|
|
- 'queues' => [
|
|
|
- [
|
|
|
- 'name' => 'queueCommon',
|
|
|
- 'passive' => false,
|
|
|
- ],
|
|
|
- [
|
|
|
- 'name' => 'informQueue',
|
|
|
- 'passive' => false,
|
|
|
- ],
|
|
|
- [
|
|
|
- 'name' => 'openShopInitQueue',
|
|
|
- 'passive' => false,
|
|
|
- ],
|
|
|
- /*
|
|
|
- [
|
|
|
- 'name' => 'queue_2',
|
|
|
- 'passive' => false,
|
|
|
- 'durable' => true,
|
|
|
- 'exclusive' => false,
|
|
|
- 'auto_delete' => false,
|
|
|
- 'nowait' => false,
|
|
|
- 'arguments' => null,
|
|
|
- 'ticket' => null,
|
|
|
- 'declare' => true,
|
|
|
- ],
|
|
|
- [
|
|
|
- 'name' => 'queue_3',
|
|
|
- 'passive' => false,
|
|
|
- 'durable' => true,
|
|
|
- 'exclusive' => false,
|
|
|
- 'auto_delete' => false,
|
|
|
- 'nowait' => false,
|
|
|
- 'arguments' => null,
|
|
|
- 'ticket' => null,
|
|
|
- 'declare' => true,
|
|
|
- ],
|
|
|
- */
|
|
|
- ],
|
|
|
-
|
|
|
- /**
|
|
|
- * 交换和队列之间的关系称为绑定
|
|
|
- * 列出绑定: rabbitmqctl list_bindings
|
|
|
- */
|
|
|
- 'bindings' => [
|
|
|
- [
|
|
|
- 'queue' => 'queueCommon',
|
|
|
- 'exchange' => 'commonExchange',
|
|
|
- 'routing_keys' => ['commonRoute'],
|
|
|
- ],
|
|
|
- [
|
|
|
- 'queue' => 'informQueue',
|
|
|
- 'exchange' => 'informExchange',
|
|
|
- 'routing_keys' => ['informRoute'],
|
|
|
- ],
|
|
|
- [
|
|
|
- 'queue' => 'openShopInitQueue',
|
|
|
- 'exchange' => 'openShopInitExchange',
|
|
|
- 'routing_keys' => ['openShopInitRoute'],
|
|
|
- ],
|
|
|
- /*
|
|
|
- [
|
|
|
- 'queue' => 'queue_2',
|
|
|
- 'exchange' => 'topic_ex_1',
|
|
|
- 'routing_keys' => ['route_1', 'route_prefix.*', '*.route_suffix', '*.*.last', '*'],
|
|
|
- ],
|
|
|
- [
|
|
|
- 'queue' => 'queue_3',
|
|
|
- 'exchange' => 'topic_ex_1',
|
|
|
- 'routing_keys' => ['route_3', 'route3_prefix.*', '*.route_suffix', '*.*.last'],
|
|
|
- ],
|
|
|
- */
|
|
|
- ],
|
|
|
-
|
|
|
- /**
|
|
|
- * 生产者
|
|
|
- */
|
|
|
- 'producers' => [
|
|
|
- [
|
|
|
- //通用生产者
|
|
|
- 'name' => 'commonProducer',
|
|
|
- ],
|
|
|
- [
|
|
|
- //通知生产者
|
|
|
- 'name' => 'informProducer',
|
|
|
- ],
|
|
|
- [
|
|
|
- //通知生产者
|
|
|
- 'name' => 'openShopInitProducer',
|
|
|
- ],
|
|
|
- /*
|
|
|
- [
|
|
|
- 'name' => 'producer_2',
|
|
|
- 'connection' => 'default',
|
|
|
- 'safe' => true,
|
|
|
- 'content_type' => 'text/plain',
|
|
|
- 'delivery_mode' => 2,
|
|
|
- 'serializer' => 'serialize',
|
|
|
- ]
|
|
|
- */
|
|
|
- ],
|
|
|
-
|
|
|
- /**
|
|
|
- * 消费者
|
|
|
- */
|
|
|
- 'consumers' => [
|
|
|
- [
|
|
|
- //常规消费者
|
|
|
- 'name' => 'commonConsumer',
|
|
|
- 'callbacks' => [
|
|
|
- 'queueCommon' => '\common\components\rabbitmq\consumer\commonConsumer', //设定队列的数据给谁转回调而以,只是个配置
|
|
|
- ],
|
|
|
- ],
|
|
|
- [
|
|
|
- //通知
|
|
|
- 'name' => 'informConsumer',
|
|
|
- 'callbacks' => [
|
|
|
- 'informQueue' => '\common\components\rabbitmq\consumer\informConsumer', //设定队列的数据给谁转回调而以,只是个配置
|
|
|
- ],
|
|
|
- ],
|
|
|
- [
|
|
|
- //授权公众号开店初始化
|
|
|
- 'name' => 'openShopInitConsumer',
|
|
|
- 'callbacks' => [
|
|
|
- 'openShopInitQueue' => '\common\components\rabbitmq\consumer\openShopInitConsumer', //设定队列的数据给谁转回调而以,只是个配置
|
|
|
- ],
|
|
|
- ],
|
|
|
- /*
|
|
|
- [
|
|
|
- 'name' => 'consumer_2',
|
|
|
- 'connection' => 'default',
|
|
|
- 'callbacks' => [
|
|
|
- 'queue_2' => '\common\components\rabbitmq\consumer\PrintMsgConsumer',
|
|
|
- ],
|
|
|
- 'qos' => [
|
|
|
- 'prefetch_size' => 0,
|
|
|
- 'prefetch_count' => 0,
|
|
|
- 'global' => false,
|
|
|
- ],
|
|
|
- 'idle_timeout' => 0,
|
|
|
- 'idle_timeout_exit_code' => null,
|
|
|
- 'proceed_on_exception' => false,
|
|
|
- 'deserializer' => 'unserialize',
|
|
|
- ],
|
|
|
- */
|
|
|
- ],
|
|
|
-];
|
|
|
-
|
|
|
-return $rabbitMQ;
|