Skip to content

Commit

Permalink
Update hoppy properties to allow additional arguments (#3270)
Browse files Browse the repository at this point in the history
## What was the problem?
This library is used by ee services to connect to RabbitMQ and define
queues. This update allows additional arguments to be specified,
including the usage of dead letter queues

Associated tickets or Slack threads:
-
[#?](#3238)

## How does this fix it?[^1]
This will let us pass arguments to specify the dead letter queue used
when a message fails to proces
  • Loading branch information
PaulKBaumann authored Aug 5, 2024
2 parents 9e3f6ae + 0b109c0 commit 10288ea
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion shared/lib-hoppy/hoppy/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.0"
__version__ = "1.0.1"
8 changes: 6 additions & 2 deletions shared/lib-hoppy/hoppy/base_queue_declarer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def _set_queue_properties(self, queue_properties: QueueProperties):
self.durable_queue = queue_properties.durable
self.auto_delete_queue = queue_properties.auto_delete
self.exclusive_queue = queue_properties.exclusive
self.arguments = queue_properties.arguments

def _on_exchange_declare_ok(self, _unused_frame):
super()._on_exchange_declare_ok(_unused_frame)
Expand All @@ -30,12 +31,14 @@ def _setup_queue(self):
passive_declare=self.passive_declare_queue,
durable=self.durable_queue,
exclusive=self.exclusive_queue,
auto_delete=self.auto_delete_exchange)
auto_delete=self.auto_delete_exchange,
arguments=self.arguments)
self._channel.queue_declare(queue=self.queue_name,
passive=self.passive_declare_queue,
durable=self.durable_queue,
exclusive=self.exclusive_queue,
auto_delete=self.auto_delete_queue,
arguments=self.arguments,
callback=self._on_queue_declare_ok)

def _on_queue_declare_ok(self, _unused_frame):
Expand All @@ -44,7 +47,8 @@ def _on_queue_declare_ok(self, _unused_frame):
passive_declare=self.passive_declare_queue,
durable=self.durable_queue,
exclusive=self.exclusive_queue,
auto_delete=self.auto_delete_exchange)
auto_delete=self.auto_delete_exchange,
arguments=self.arguments)
self._debug('bindingQueue',
queue=self.queue_name,
exchange=self.exchange_name,
Expand Down
3 changes: 2 additions & 1 deletion shared/lib-hoppy/hoppy/hoppy_properties.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass

from dataclasses import field

@dataclass
class ExchangeProperties:
Expand All @@ -17,3 +17,4 @@ class QueueProperties:
durable: bool = True
auto_delete: bool = True
exclusive: bool = False
arguments: dict = field(default_factory=dict)

0 comments on commit 10288ea

Please sign in to comment.