Skip to content

Commit

Permalink
Use configured settings when replaying domain event
Browse files Browse the repository at this point in the history
The default settings are still active at import time. Running
`replay_event` would use the default broker instead of the configured
broker.

Set the connection settings at runtime also when replaying events.
  • Loading branch information
Pankrat committed Mar 23, 2021
1 parent e2f9d1d commit 2a76bff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [3.0.2]

### Fixed

- Use configured broker when replaying domain events

## [3.0.1]

### Fixed
Expand Down
6 changes: 4 additions & 2 deletions domain_event_broker/replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def retry_event(body: bytes, **kwargs: Any) -> str:

def replay_event(queue_name: str,
message_callback: Callable = retry_event,
connection_settings: Optional[str] = settings.BROKER,
connection_settings: Optional[str] = '',
) -> int:
"""
Move one domain event from a dead-letter queue back into the processing queue.
Expand All @@ -29,6 +29,8 @@ def replay_event(queue_name: str,
"""
if connection_settings is None:
return 0
elif connection_settings == '':
connection_settings = settings.BROKER
retry_exchange = queue_name + '-retry'
dead_letter_queue = queue_name + '-dl'
transport = Transport(connection_settings)
Expand Down Expand Up @@ -56,7 +58,7 @@ def replay_event(queue_name: str,

def replay_all(queue_name: str,
message_callback: Callable = retry_event,
connection_settings: Optional[str] = settings.BROKER,
connection_settings: Optional[str] = '',
) -> int:
"""
Replay all messages currently in the dead-letter queue.
Expand Down

0 comments on commit 2a76bff

Please sign in to comment.