Skip to content

Commit

Permalink
Adjust message queue error handling (hyperledger#3170)
Browse files Browse the repository at this point in the history
Signed-off-by: jamshale <jamiehalebc@gmail.com>
  • Loading branch information
jamshale committed Aug 20, 2024
1 parent f29e67e commit 96e8315
Showing 1 changed file with 27 additions and 24 deletions.
51 changes: 27 additions & 24 deletions aries_cloudagent/transport/outbound/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,40 +470,43 @@ def deliver_queued_message(self, queued: QueuedOutboundMessage) -> asyncio.Task:
)
return queued.task

def _finished_deliver_error_handler(self, queued: QueuedOutboundMessage, retry: bool):
if retry:
LOGGER.debug(
(
">>> Error when posting to: %s; "
"Error: %s; "
"Payload: %s; Re-queue failed message ..."
),
queued.endpoint,
queued.error,
queued.payload,
)
else:
err_msg = ">>> Outbound message failed to deliver, NOT Re-queued."
if "/webhook/topic" in queued.endpoint:
LOGGER.warning(
err_msg,
exc_info=queued.error,
)
else:
LOGGER.exception(
err_msg,
exc_info=queued.error,
)

def finished_deliver(self, queued: QueuedOutboundMessage, completed: CompletedTask):
"""Handle completion of queued message delivery."""
if completed.exc_info:
queued.error = completed.exc_info

if queued.retries:
if LOGGER.isEnabledFor(logging.DEBUG):
LOGGER.error(
(
">>> Error when posting to: %s; "
"Error: %s; "
"Payload: %s; Re-queue failed message ..."
),
queued.endpoint,
queued.error,
queued.payload,
)
else:
LOGGER.error(
(
">>> Error when posting to: %s; "
"Error: %s; Re-queue failed message ..."
),
queued.endpoint,
queued.error,
)
self._finished_deliver_error_handler(queued, retry=True)
queued.retries -= 1
queued.state = QueuedOutboundMessage.STATE_RETRY
queued.retry_at = time.perf_counter() + 10
else:
LOGGER.exception(
">>> Outbound message failed to deliver, NOT Re-queued.",
exc_info=queued.error,
)
self._finished_deliver_error_handler(queued, retry=False)
queued.state = QueuedOutboundMessage.STATE_DONE
else:
queued.error = None
Expand Down

0 comments on commit 96e8315

Please sign in to comment.