Files
datahub/backend/config/autoload/amqp.php
T

152 lines
5.3 KiB
PHP
Raw Normal View History

2025-11-17 16:51:51 +08:00
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
use Hyperf\Amqp\IO\IOFactory;
use function Hyperf\Support\env;
2025-11-26 09:44:29 +08:00
// use App\Platform\OrderConsumer;
2025-11-17 16:51:51 +08:00
return [
'enable' => true,
2026-03-17 10:36:12 +08:00
'management' => [
'host' => env('AMQP_HOST', 'localhost'),
'port' => (int) env('RABBITMQ_MANAGEMENT_PORT', 15672),
'user' => env('AMQP_ADMIN_USER', 'guest'),
'password' => env('AMQP_ADMIN_PASSWORD', 'guest'),
],
2025-11-26 09:44:29 +08:00
'default_producer' => [
2025-11-17 16:51:51 +08:00
'host' => env('AMQP_HOST', 'localhost'),
'port' => (int) env('AMQP_PORT', 5672),
'user' => env('AMQP_USER', 'guest'),
'password' => env('AMQP_PASSWORD', 'guest'),
'vhost' => env('AMQP_VHOST', '/'),
'open_ssl' => false,
'concurrent' => [
2025-11-26 09:44:29 +08:00
'limit' => 1,
2025-11-17 16:51:51 +08:00
],
'pool' => [
'connections' => 2,
],
'io' => IOFactory::class,
'params' => [
'insist' => false,
'login_method' => 'AMQPLAIN',
'login_response' => null,
'locale' => 'en_US',
'connection_timeout' => 3,
// Try to maintain twice value heartbeat as much as possible
'read_write_timeout' => 6,
'context' => null,
'keepalive' => true,
// Try to ensure that the consumption time of each message is less than the heartbeat time as much as possible
'heartbeat' => 3,
'channel_rpc_timeout' => 0.0,
'close_on_destruct' => false,
'max_idle_channels' => 10,
'connection_name' => null,
],
],
2025-11-26 09:44:29 +08:00
'default_consumer' => [
'host' => env('AMQP_HOST', 'localhost'),
'port' => (int) env('AMQP_PORT', 5672),
2026-02-04 15:55:59 +08:00
'user' => 'user_datahub_consumer',
'password' => env('MQ_PASSWORD_CONSUMER', 'password'),
2025-11-26 09:44:29 +08:00
'vhost' => env('AMQP_VHOST', '/'),
'open_ssl' => false,
'concurrent' => [
'limit' => 1,
],
'pool' => [
'connections' => 2,
],
'io' => IOFactory::class,
'params' => [
'insist' => false,
'login_method' => 'AMQPLAIN',
'login_response' => null,
'locale' => 'en_US',
'connection_timeout' => 3,
// Try to maintain twice value heartbeat as much as possible
'read_write_timeout' => 6,
'context' => null,
'keepalive' => true,
// Try to ensure that the consumption time of each message is less than the heartbeat time as much as possible
'heartbeat' => 3,
'channel_rpc_timeout' => 0.0,
'close_on_destruct' => false,
'max_idle_channels' => 10,
'connection_name' => null,
],
],
// consumers 配置改为使用 注解方式定义,这里仅保留注释作为备注
// 'consumers' => [
// Orders Consumer - Single queue for all platforms
// [
// 'exchange' => 'main.exchange',
// 'routingKey' => 'order.#',
// 'queue' => 'orders.queue',
// 'consumer' => OrderConsumer::class,
// 'nums' => 1,
// 'enable' => true,
// 'maxConsumption' => 0,
// 'qos' => [
// 'prefetch_size' => 0,
// 'prefetch_count' => 100,
// 'global' => false,
// ],
// ],
// Products Consumer - Single queue for all platforms (commented out until ProductConsumer is implemented)
// [
// 'exchange' => 'main.exchange',
// 'routingKey' => 'product.#',
// 'queue' => 'products.queue',
// 'consumer' => ProductConsumer::class,
// 'nums' => 1,
// 'enable' => true,
// 'maxConsumption' => 0,
// 'qos' => [
// 'prefetch_size' => 0,
// 'prefetch_count' => 100,
// 'global' => false,
// ],
// ],
// Refunds Consumer - Single queue for all platforms (commented out until RefundConsumer is implemented)
// [
// 'exchange' => 'main.exchange',
// 'routingKey' => 'refund.#',
// 'queue' => 'refunds.queue',
// 'consumer' => RefundConsumer::class,
// 'nums' => 1,
// 'enable' => true,
// 'maxConsumption' => 0,
// 'qos' => [
// 'prefetch_size' => 0,
// 'prefetch_count' => 100,
// 'global' => false,
// ],
// ],
// Inventory Consumer - Single queue for all platforms (commented out until InventoryConsumer is implemented)
// [
// 'exchange' => 'main.exchange',
// 'routingKey' => 'inventory.#',
// 'queue' => 'inventory.queue',
// 'consumer' => InventoryConsumer::class,
// 'nums' => 1,
// 'enable' => true,
// 'maxConsumption' => 0,
// 'qos' => [
// 'prefetch_size' => 0,
// 'prefetch_count' => 100,
// 'global' => false,
// ],
// ],
// ],
];