File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace Enqueue \LaravelQueue ;
4
4
5
+ use Enqueue \AmqpTools \DelayStrategy ;
5
6
use Enqueue \AmqpTools \DelayStrategyAware ;
7
+ use Enqueue \AmqpTools \RabbitMqDelayPluginDelayStrategy ;
6
8
use Enqueue \AmqpTools \RabbitMqDlxDelayStrategy ;
7
9
use Interop \Amqp \AmqpContext ;
8
10
@@ -12,15 +14,25 @@ public function connect(array $config)
12
14
{
13
15
$ queue = parent ::connect ($ config );
14
16
17
+ $ config = array_replace (['delay_strategy ' => 'rabbitmq_dlx ' ], $ config );
18
+
19
+
20
+
15
21
/** @var AmqpContext $amqpContext */
16
22
$ amqpContext = $ queue ->getPsrContext ();
17
23
if (false == $ amqpContext instanceof AmqpContext) {
18
24
throw new \LogicException (sprintf ('The context must be instance of "%s" but got "%s" ' , AmqpContext::class, get_class ($ queue ->getPsrContext ())));
19
25
}
20
26
21
- if ($ amqpContext instanceof DelayStrategyAware) {
27
+ if ($ amqpContext instanceof DelayStrategyAware && ' rabbitmq_dlx ' == $ config [ ' delay_strategy ' ] ) {
22
28
$ amqpContext ->setDelayStrategy (new RabbitMqDlxDelayStrategy ());
23
29
}
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
+ }
24
36
25
37
return $ queue ;
26
38
}
You can’t perform that action at this time.
0 commit comments