Skip to content

Conversation

@huangdijia
Copy link
Member

Summary

This PR introduces automatic consumer process registration for async queues based on configuration settings, simplifying the setup process and providing more flexibility for users.

Changes

  • ConsumerManager: New class that manages the creation and registration of consumer processes based on configuration
  • RegisterConsumerProcessesListener: Automatically registers consumer processes when the server starts (supports both BeforeMainServerStart and MainCoroutineServerStart events)
  • Configuration enhancement: Added enable option to control automatic process registration per queue
  • Config template update: Updated the published configuration file with documentation for the new enable option

Benefits

  1. Simplified setup: Users no longer need to manually register consumer processes in config/autoload/processes.php
  2. Per-queue control: The enable option allows granular control over which queues should auto-register consumer processes
  3. Backward compatible: Existing configurations continue to work as expected (defaults to disabled if not specified)

Configuration Example

return [
    'default' => [
        'enable' => true, // Enable auto-registration for this queue
        'driver' => RedisDriver::class,
        'redis' => [
            'pool' => 'default',
        ],
        'processes' => 1,
        // ... other options
    ],
];

Test plan

  • Verify that consumer processes are automatically registered when enable is set to true
  • Verify that consumer processes are not registered when enable is false or not set
  • Verify compatibility with both server start events
  • Verify that existing manual process registration continues to work
  • Test with multiple queue configurations

…on configuration

This change introduces a new feature that allows async queue consumer processes to be automatically registered based on configuration settings, simplifying the setup process for users.

Changes:
- Add ConsumerManager class to manage consumer process creation and registration
- Add RegisterConsumerProcessesListener to automatically register processes on server start
- Add 'enable' configuration option to control automatic process registration per queue
- Update ConfigProvider to register the new listener
- Update config template with 'enable' option documentation

This feature provides more flexibility by allowing users to enable/disable consumer process auto-registration per queue through configuration, eliminating the need for manual process registration in config/autoload/processes.php.
@huangdijia huangdijia added this to the v3.2 milestone Nov 12, 2025
@limingxinleo limingxinleo merged commit 41341d3 into hyperf:3.2 Nov 12, 2025
76 checks passed
@huangdijia huangdijia deleted the feat/async-queue-auto-register-consumer-processes branch November 12, 2025 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants