rabbitMQ.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. /**
  3. * rabbitmq的配置
  4. */
  5. $rabbitMQ = [
  6. 'class' => 'mikemadisonweb\rabbitmq\Configuration',
  7. 'connections' => [
  8. [
  9. 'host' => '127.0.0.1',
  10. 'port' => '5672',
  11. 'user' => 'admin',
  12. 'password' => 'Kn3oaz138w52kzmm9',
  13. 'vhost' => '/', //虚拟主机
  14. ]
  15. ],
  16. /**
  17. * 交换器
  18. */
  19. 'exchanges' => [
  20. [
  21. 'name' => 'customExchange',
  22. 'type' => 'direct',
  23. 'durable' => true,
  24. ],
  25. [
  26. 'name' => 'stockExchange',
  27. 'type' => 'direct',
  28. 'durable' => true,
  29. ],
  30. [
  31. 'name' => 'notifyExchange',
  32. 'type' => 'direct',
  33. 'durable' => true,
  34. ],
  35. [
  36. 'name' => 'ptExchange',
  37. 'type' => 'direct',
  38. 'durable' => true,
  39. ]
  40. ],
  41. /**
  42. * 队列
  43. */
  44. 'queues' => [
  45. [
  46. 'name' => 'customQueue',
  47. 'passive' => false,
  48. 'durable' => true,
  49. ],
  50. [
  51. 'name' => 'stockQueue',
  52. 'passive' => false,
  53. 'durable' => true,
  54. ],
  55. [
  56. 'name' => 'notifyQueue',
  57. 'passive' => false,
  58. 'durable' => true,
  59. ],
  60. [
  61. 'name' => 'ptQueue',
  62. 'passive' => false,
  63. 'durable' => true,
  64. ],
  65. ],
  66. /**
  67. * 交换和队列之间的关系称为绑定
  68. * 列出绑定: rabbitmqctl list_bindings
  69. */
  70. 'bindings' => [
  71. [
  72. 'queue' => 'customQueue',
  73. 'exchange' => 'customExchange',
  74. 'routing_keys' => ['customRoute'],
  75. ],
  76. [
  77. 'queue' => 'stockQueue',
  78. 'exchange' => 'stockExchange',
  79. 'routing_keys' => ['stockRoute'],
  80. ],
  81. [
  82. 'queue' => 'notifyQueue',
  83. 'exchange' => 'notifyExchange',
  84. 'routing_keys' => ['notifyRoute'],
  85. ],
  86. [
  87. 'queue' => 'ptQueue',
  88. 'exchange' => 'ptExchange',
  89. 'routing_keys' => ['ptRoute'],
  90. ]
  91. ],
  92. /**
  93. * 生产者
  94. */
  95. 'producers' => [
  96. [
  97. //客户操作生产者
  98. 'name' => 'customProducer',
  99. ],
  100. [
  101. //库存管理生产者
  102. 'name' => 'stockProducer',
  103. ],
  104. [
  105. //通知生产者
  106. 'name' => 'notifyProducer',
  107. ],
  108. [
  109. //跑腿下单生产者
  110. 'name' => 'ptProducer',
  111. ],
  112. ],
  113. /**
  114. * 消费者
  115. */
  116. 'consumers' => [
  117. [
  118. //客户操作消费者
  119. 'name' => 'customConsumer',
  120. 'callbacks' => [
  121. 'customQueue' => '\common\components\rabbitmq\customConsumer',
  122. ]
  123. ],
  124. [
  125. //库存管理消费者
  126. 'name' => 'stockConsumer',
  127. 'callbacks' => [
  128. 'stockQueue' => '\common\components\rabbitmq\stockConsumer',
  129. ]
  130. ],
  131. [
  132. //通知消费者
  133. 'name' => 'notifyConsumer',
  134. 'callbacks' => [
  135. 'notifyQueue' => '\common\components\rabbitmq\notifyConsumer',
  136. ]
  137. ],
  138. [
  139. //跑腿下单消费者
  140. 'name' => 'ptConsumer',
  141. 'callbacks' => [
  142. 'ptQueue' => '\common\components\rabbitmq\ptConsumer',
  143. ]
  144. ],
  145. ],
  146. ];
  147. return $rabbitMQ;