Skip to content

Commit 4f9c4a5

Browse files
committed
amqp delay message with dlx strategy.
1 parent 9a2c2a6 commit 4f9c4a5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/AmqpConnector.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Enqueue\LaravelQueue;
44

5+
use Enqueue\AmqpTools\DelayStrategyAware;
6+
use Enqueue\AmqpTools\RabbitMqDlxDelayStrategy;
57
use Interop\Amqp\AmqpContext;
68

79
class AmqpConnector extends Connector
@@ -10,11 +12,15 @@ public function connect(array $config)
1012
{
1113
$queue = parent::connect($config);
1214

13-
if (false == $queue->getPsrContext() instanceof AmqpContext) {
14-
throw new \LogicException(sprintf('The context must be instance of "%s" but got "%s"', AmqpContext::class, get_class($queue->getPsrContext()));
15+
/** @var AmqpContext $amqpContext */
16+
$amqpContext = $queue->getPsrContext();
17+
if (false == $amqpContext instanceof AmqpContext) {
18+
throw new \LogicException(sprintf('The context must be instance of "%s" but got "%s"', AmqpContext::class, get_class($queue->getPsrContext())));
1519
}
1620

17-
// TODO set delay strategy.
21+
if ($amqpContext instanceof DelayStrategyAware) {
22+
$amqpContext->setDelayStrategy(new RabbitMqDlxDelayStrategy());
23+
}
1824

1925
return $queue;
2026
}

0 commit comments

Comments
 (0)