horizon: Configuring the queue to be processed by a separate server to the main application server adds the job to the wrong redis store

  • Horizon Version: 5.7.17
  • Laravel Version: 8.76.2
  • PHP Version: 7.4.24
  • Redis Driver & Version: predis 1.1.9
  • Database Driver & Version: MySQL 5.7.36

Description:

If you configure a custom redis connection for an external server in config/database.php and then set that as the redis queue connection in config/queue.php, queued jobs are added to the local redis store on the application server instead of being pushed to the external server redis store that is configured for use.

Steps To Reproduce:

  • Install a fresh laravel application and horizon.
  • Add a new entry to the redis array in config/database.php and add the environment variables for the external redis server
'queue' => [
    'url' => env('REDIS_QUEUE_URL'),
    'host' => env('REDIS_QUEUE_HOST', '127.0.0.1'),
    'password' => env('REDIS_QUEUE_PASSWORD', null),
    'port' => env('REDIS_QUEUE_PORT', '6379'),
    'database' => env('REDIS_QUEUE_DB', '0'),
]
  • Update the connection value to ‘queue’ for the redis entry in config/queue.php
'redis' => [
    'driver' => 'redis',
    'connection' => 'queue',
    'queue' => env('REDIS_QUEUE', 'default'),
    'retry_after' => 90,
    'block_for' => null,
    'after_commit' => false,
]

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

So it really was a configuration issue.

The jobs were dispatched without inConnection() value so they all went into the default one.

My confusion was that I thought Horizon handles that when I set the connection in the supervisor. But I now understand it only look for dispatched jobs there.

We learn a new thing every day 😃

Thanks for your time replying and linking to those resources 🙏

@matt-ostrom-hall-rss I’m not sure if I’ll ever be able to reproduce that. It worked for me the last time I tried. I’m not convinced there’s an issue but rather a configuration issue. It’s best that you try a support channel: