Skip to content

Add multi-connection support for multiple databases#465

Merged
dereuromark merged 2 commits intomasterfrom
feature/multi-connection-support
Mar 18, 2026
Merged

Add multi-connection support for multiple databases#465
dereuromark merged 2 commits intomasterfrom
feature/multi-connection-support

Conversation

@dereuromark
Copy link
Owner

Summary

Add support for running queue workers and admin interface across multiple database connections (e.g., primary and secondary databases).

Features:

  • Configure connections via Queue.connections array in config
  • Connection switcher dropdown in admin navigation bar
  • --connection option for queue run and queue job commands
  • Whitelist validation for security (only configured connections allowed)
  • Backwards compatible - only activates with 2+ connections configured

Configuration example:

$config['Queue']['connections'] = ['default', 'acme'];

The first connection in the array is used as the default. Workers must be run separately for each connection to process its jobs:

bin/cake queue run                    # Process default connection
bin/cake queue run --connection acme  # Process acme connection

Documentation: Added comprehensive documentation in docs/sections/multi_connection.md covering:

  • Configuration setup
  • Admin dashboard usage
  • CLI commands
  • Creating jobs for specific connections
  • Production deployment (cron/supervisor)
  • Database migrations per connection
  • Troubleshooting

Use case: Applications with multi-tenant architectures or separate databases for different parts of the system.

Add support for running queue workers and admin interface across
multiple database connections (e.g., primary and secondary databases).

Features:
- Configure connections via Queue.connections array in config
- Connection switcher dropdown in admin navigation
- --connection option for queue run and queue job commands
- Whitelist validation for security
- Backwards compatible - only activates with 2+ connections

Configuration example:
$config['Queue']['connections'] = ['default', 'acme'];

The first connection in the array is used as the default. Workers
must be run separately for each connection to process its jobs.
@codecov-commenter
Copy link

codecov-commenter commented Mar 18, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 56.97674% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.73%. Comparing base (3eb9ec4) to head (45e99c2).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/Controller/Admin/QueueAppController.php 39.28% 17 Missing ⚠️
src/Queue/Processor.php 46.66% 8 Missing ⚠️
src/Command/JobCommand.php 66.66% 7 Missing ⚠️
src/Controller/Admin/QueueController.php 62.50% 3 Missing ⚠️
src/Controller/Admin/QueueProcessesController.php 75.00% 1 Missing ⚠️
src/Controller/Admin/QueuedJobsController.php 50.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #465      +/-   ##
============================================
- Coverage     77.32%   76.73%   -0.59%     
- Complexity      888      926      +38     
============================================
  Files            45       45              
  Lines          3069     3151      +82     
============================================
+ Hits           2373     2418      +45     
- Misses          696      733      +37     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Use session to persist connection choice across requests
- Query param ?connection=xxx sets session value
- Connection switcher redirects to dashboard to avoid 404s
- Fix CS issue with RuntimeException import
@dereuromark dereuromark merged commit c63f624 into master Mar 18, 2026
16 checks passed
@dereuromark dereuromark deleted the feature/multi-connection-support branch March 18, 2026 17:52
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