-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement RabbitMQ dead-letter queue handling and retry mechanism; re…
…factor callback function to explicitly acknowledge completion
- Loading branch information
Showing
2 changed files
with
103 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
@startuml Sequence Diagram | ||
participant FlaskApp | ||
participant Logger | ||
participant Postgres | ||
participant RabbitMQ | ||
|
||
User -> FlaskApp: Start Application | ||
activate FlaskApp | ||
FlaskApp -> FlaskApp: consume_messages() | ||
activate RabbitMQ | ||
|
||
FlaskApp -> RabbitMQ: connect to RabbitMQ | ||
alt Connection Successful | ||
RabbitMQ -> RabbitMQ: start_consuming() | ||
loop While Consuming | ||
RabbitMQ -> RabbitMQ: callback() | ||
activate RabbitMQ | ||
RabbitMQ -> RabbitMQ: json.loads(body) | ||
RabbitMQ -> Postgres: connect_to_postgres() | ||
activate Postgres | ||
alt Connection Successful | ||
Postgres -> Postgres: Insert data into Postgres | ||
Postgres -> Postgres: commit() | ||
else Connection Failed | ||
RabbitMQ -> RabbitMQ: Send to dead letter exchange to be requeued | ||
end | ||
deactivate Postgres | ||
RabbitMQ -> RabbitMQ: ack() | ||
RabbitMQ -> Postgres: close connection | ||
deactivate RabbitMQ | ||
end | ||
else Connection Failed | ||
RabbitMQ -> RabbitMQ: time.sleep(5) | ||
end | ||
deactivate RabbitMQ | ||
deactivate FlaskApp | ||
@enduml |