File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 22
33namespace Enqueue \LaravelQueue ;
44
5+ use Enqueue \AmqpTools \DelayStrategy ;
56use Enqueue \AmqpTools \DelayStrategyAware ;
7+ use Enqueue \AmqpTools \RabbitMqDelayPluginDelayStrategy ;
68use Enqueue \AmqpTools \RabbitMqDlxDelayStrategy ;
79use Interop \Amqp \AmqpContext ;
810
@@ -12,15 +14,25 @@ public function connect(array $config)
1214 {
1315 $ queue = parent ::connect ($ config );
1416
17+ $ config = array_replace (['delay_strategy ' => 'rabbitmq_dlx ' ], $ config );
18+
19+
20+
1521 /** @var AmqpContext $amqpContext */
1622 $ amqpContext = $ queue ->getPsrContext ();
1723 if (false == $ amqpContext instanceof AmqpContext) {
1824 throw new \LogicException (sprintf ('The context must be instance of "%s" but got "%s" ' , AmqpContext::class, get_class ($ queue ->getPsrContext ())));
1925 }
2026
21- if ($ amqpContext instanceof DelayStrategyAware) {
27+ if ($ amqpContext instanceof DelayStrategyAware && ' rabbitmq_dlx ' == $ config [ ' delay_strategy ' ] ) {
2228 $ amqpContext ->setDelayStrategy (new RabbitMqDlxDelayStrategy ());
2329 }
30+ if ($ amqpContext instanceof DelayStrategyAware && 'rabbitmq_delay_plugin ' == $ config ['delay_strategy ' ]) {
31+ $ amqpContext ->setDelayStrategy (new RabbitMqDelayPluginDelayStrategy ());
32+ }
33+ if ($ amqpContext instanceof DelayStrategyAware && $ config ['delay_strategy ' ] instanceof DelayStrategy) {
34+ $ amqpContext ->setDelayStrategy ($ config ['delay_strategy ' ]);
35+ }
2436
2537 return $ queue ;
2638 }
You can’t perform that action at this time.
0 commit comments