| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- <?php
- /**
- * rabbitmq的配置
- */
- $rabbitMQ = [
- 'class' => 'mikemadisonweb\rabbitmq\Configuration',
- 'connections' => [
- [
- 'host' => '127.0.0.1',
- 'port' => '5672',
- 'user' => 'admin',
- 'password' => 'Kn3oaz138w52kzmm9',
- 'vhost' => '/', //虚拟主机
- ]
- ],
- /**
- * 交换器
- */
- 'exchanges' => [
- [
- 'name' => 'customExchange',
- 'type' => 'direct',
- 'durable' => true,
- ],
- [
- 'name' => 'stockExchange',
- 'type' => 'direct',
- 'durable' => true,
- ],
- [
- 'name' => 'notifyExchange',
- 'type' => 'direct',
- 'durable' => true,
- ],
- [
- 'name' => 'ptExchange',
- 'type' => 'direct',
- 'durable' => true,
- ],
- [
- 'name' => 'limitBuyDelayExchange',
- 'type' => 'x-delayed-message',
- 'durable' => true,
- 'arguments' => new \PhpAmqpLib\Wire\AMQPTable([
- 'x-delayed-type' => 'direct',
- ]),
- ]
- ],
- /**
- * 队列
- */
- 'queues' => [
- [
- 'name' => 'customQueue',
- 'passive' => false,
- 'durable' => true,
- ],
- [
- 'name' => 'stockQueue',
- 'passive' => false,
- 'durable' => true,
- ],
- [
- 'name' => 'notifyQueue',
- 'passive' => false,
- 'durable' => true,
- ],
- [
- 'name' => 'ptQueue',
- 'passive' => false,
- 'durable' => true,
- ],
- [
- 'name' => 'limitBuyQueue',
- 'passive' => false,
- 'durable' => true,
- ],
- [
- 'name' => 'birthdayGiftQueue',
- 'passive' => false,
- 'durable' => true,
- ],
- ],
- /**
- * 交换和队列之间的关系称为绑定
- * 列出绑定: rabbitmqctl list_bindings
- */
- 'bindings' => [
- [
- 'queue' => 'customQueue',
- 'exchange' => 'customExchange',
- 'routing_keys' => ['customRoute'],
- ],
- [
- 'queue' => 'stockQueue',
- 'exchange' => 'stockExchange',
- 'routing_keys' => ['stockRoute'],
- ],
- [
- 'queue' => 'notifyQueue',
- 'exchange' => 'notifyExchange',
- 'routing_keys' => ['notifyRoute'],
- ],
- [
- 'queue' => 'ptQueue',
- 'exchange' => 'ptExchange',
- 'routing_keys' => ['ptRoute'],
- ],
- [
- 'queue' => 'limitBuyQueue',
- 'exchange' => 'limitBuyDelayExchange',
- 'routing_keys' => ['limitBuyDelayRoute'],
- ],
- [
- 'queue' => 'birthdayGiftQueue',
- 'exchange' => 'limitBuyDelayExchange',
- 'routing_keys' => ['birthdayGiftDelayRoute'],
- ]
- ],
- /**
- * 生产者
- */
- 'producers' => [
- [
- //客户操作生产者
- 'name' => 'customProducer',
- ],
- [
- //库存管理生产者
- 'name' => 'stockProducer',
- ],
- [
- //通知生产者
- 'name' => 'notifyProducer',
- ],
- [
- //跑腿下单生产者
- 'name' => 'ptProducer',
- ]
- ],
- /**
- * 消费者
- */
- 'consumers' => [
- [
- //客户操作消费者
- 'name' => 'customConsumer',
- 'callbacks' => [
- 'customQueue' => '\common\components\rabbitmq\customConsumer',
- ]
- ],
- [
- //库存管理消费者
- 'name' => 'stockConsumer',
- 'callbacks' => [
- 'stockQueue' => '\common\components\rabbitmq\stockConsumer',
- //'limitBuyQueue' => '\common\components\rabbitmq\cancelLimitBuyConsumer',
- 'limitBuyQueue' => '\common\components\rabbitmq\stockConsumer',
- 'birthdayGiftQueue' => '\common\components\rabbitmq\stockConsumer', //生日礼物队列
- ]
- ],
- [
- //通知消费者
- 'name' => 'notifyConsumer',
- 'callbacks' => [
- 'notifyQueue' => '\common\components\rabbitmq\notifyConsumer',
- ]
- ],
- [
- //跑腿下单消费者
- 'name' => 'ptConsumer',
- 'callbacks' => [
- 'ptQueue' => '\common\components\rabbitmq\ptConsumer',
- ]
- ],
- // [ // 生日礼物队列不独创自己的消费者
- // 'name' => 'birthdayGiftConsumer',
- // 'callbacks' => [
- // 'birthdayGiftQueue' => '\common\components\rabbitmq\birthdayGiftConsumer',
- // ]
- // ]
- ],
- ];
- return $rabbitMQ;
|