File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
src/VladimirYuldashev/LaravelQueueRabbitMQ/Queue Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,10 @@ class RabbitMQQueue extends Queue implements QueueContract
2222 protected $ channel ;
2323
2424 protected $ declareExchange ;
25+ protected $ declaredExchanges = [];
26+
2527 protected $ declareBindQueue ;
28+ protected $ declaredBindQueue = [];
2629
2730 protected $ defaultQueue ;
2831 protected $ configQueue ;
@@ -172,7 +175,8 @@ private function declareQueue($name)
172175 $ name = $ this ->getQueueName ($ name );
173176 $ exchange = $ this ->configExchange ['name ' ] ?: $ name ;
174177
175- if ($ this ->declareExchange ) {
178+ if ($ this ->declareExchange && ! in_array ($ exchange , $ this ->declaredExchanges )) {
179+ $ this ->declaredExchanges [] = $ exchange ;
176180 // declare exchange
177181 $ this ->channel ->exchange_declare (
178182 $ exchange ,
@@ -183,7 +187,8 @@ private function declareQueue($name)
183187 );
184188 }
185189
186- if ($ this ->declareBindQueue ) {
190+ if ($ this ->declareBindQueue && ! in_array ($ name , $ this ->declaredBindQueue )) {
191+ $ this ->declaredBindQueue [] = $ name ;
187192 // declare queue
188193 $ this ->channel ->queue_declare (
189194 $ name ,
You can’t perform that action at this time.
0 commit comments