Skip to content

Commit

Permalink
fixes submission of custom headers for DLX
Browse files Browse the repository at this point in the history
  • Loading branch information
amenezes committed Aug 9, 2023
1 parent ff8abee commit ebe69f8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rabbit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .queue import Queue
from .subscribe import Subscribe

__version__ = "3.0.1"
__version__ = "3.0.2"
__all__ = [
"__version__",
"AioRabbitClient",
Expand Down
13 changes: 10 additions & 3 deletions rabbit/dlx.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ async def send_event(
) -> None:
"""Sent event message to DLX/DLQ."""
timeout = self.delay_strategy(properties.headers)
properties = await self._get_properties(timeout, cause, envelope)
properties = await self._get_properties(timeout, cause, envelope, properties)

logger.debug(
f"Send event to dlq: [exchange: {self.exchange.name}"
Expand All @@ -111,9 +111,13 @@ async def send_event(
raise OperationError("Ensure that instance was connected ")

async def _get_properties(
self, timeout: int, exception_message: Exception, envelope: Envelope
self,
timeout: int,
exception_message: Exception,
envelope: Envelope,
properties: Properties,
) -> dict:
return {
custom_properties: dict = {
"expiration": f"{timeout}",
"headers": {
"x-delay": f"{timeout}",
Expand All @@ -122,3 +126,6 @@ async def _get_properties(
"x-original-routingKey": f"{envelope.routing_key}",
},
}
if properties.headers is not None:
custom_properties["headers"].update(properties.headers)
return custom_properties
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = async rabbit client
long_description = file: README.md
long_description_content_type = text/markdown
license = Apache-2.0
license_file = LICENSE
license_files = LICENSE
url = https://github.com/amenezes/rabbit-client
project_urls =
Documentation = https://rabbit-client.amenezes.net
Expand Down

0 comments on commit ebe69f8

Please sign in to comment.