Fixes #6646 -- Pass settings to Redis transport, which manually reconnects using them.

This commit is contained in:
Buster Neece 2023-11-29 19:25:47 -06:00
parent 1657f2271e
commit fc45e38095
No known key found for this signature in database
2 changed files with 11 additions and 4 deletions

View File

@ -322,9 +322,10 @@ return [
App\MessageQueue\QueueManagerInterface::class => static function (
App\Service\RedisFactory $redisFactory,
Environment $environment
) {
return ($redisFactory->isSupported())
? new App\MessageQueue\QueueManager($redisFactory)
? new App\MessageQueue\QueueManager($environment)
: new App\MessageQueue\TestQueueManager();
},

View File

@ -4,7 +4,8 @@ declare(strict_types=1);
namespace App\MessageQueue;
use App\Service\RedisFactory;
use App\Environment;
use Redis;
use Symfony\Component\Messenger\Bridge\Redis\Transport\Connection;
use Symfony\Component\Messenger\Bridge\Redis\Transport\RedisTransport;
use Symfony\Component\Messenger\Exception\TransportException;
@ -15,7 +16,7 @@ final class QueueManager extends AbstractQueueManager
private array $connections = [];
public function __construct(
private readonly RedisFactory $redisFactory
private readonly Environment $environment
) {
}
@ -49,14 +50,19 @@ final class QueueManager extends AbstractQueueManager
$queueName = $queue->value;
if (!isset($this->connections[$queueName])) {
$redisSettings = $this->environment->getRedisSettings();
$this->connections[$queueName] = new Connection(
[
'host' => $redisSettings['host'],
'port' => $redisSettings['port'],
'dbindex' => $redisSettings['db'],
'stream' => 'messages.' . $queueName,
'delete_after_ack' => true,
'redeliver_timeout' => 43200,
'claim_interval' => 86400,
],
$this->redisFactory->createInstance()
new Redis()
);
}