Skip to content

Commit 786da53

Browse files
committed
avoid declaring the wrong queue, drop unreachable block
1 parent 4fde2a4 commit 786da53

File tree

2 files changed

+1
-11
lines changed

2 files changed

+1
-11
lines changed

dramatiq/brokers/rabbitmq.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from threading import Event, local
2525

2626
import pika
27-
from pika.exceptions import ChannelClosedByBroker
2827

2928
from ..broker import Broker, Consumer, MessageProxy
3029
from ..common import current_millis, dq_name, q_name, xq_name
@@ -324,7 +323,7 @@ def enqueue(self, message, *, delay=None):
324323
attempts = 1
325324
while True:
326325
try:
327-
self.declare_queue(queue_name, ensure=True)
326+
self.declare_queue(message.queue_name, ensure=True)
328327
self.logger.debug("Enqueueing message %r on queue %r.", message.message_id, queue_name)
329328
self.emit_before("enqueue", message, delay)
330329
self.channel.basic_publish(
@@ -345,13 +344,6 @@ def enqueue(self, message, *, delay=None):
345344
# next caller/attempt may initiate new ones of each.
346345
del self.connection
347346

348-
# When a queue has been deleted, attempt to get it
349-
# redeclared by removing it from the known set. The next
350-
# time a message is enqueued -- which could be when we
351-
# retry this block -- it will be redeclared.
352-
if isinstance(e, ChannelClosedByBroker) and e.reply_code == 404:
353-
self.queues.remove(q_name(queue_name))
354-
355347
attempts += 1
356348
if attempts > MAX_ENQUEUE_ATTEMPTS:
357349
raise ConnectionClosed(e) from None

tests/test_rabbitmq.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import os
2-
import random
3-
import string
42
import time
53
from threading import Event
64
from unittest.mock import Mock, patch

0 commit comments

Comments
 (0)