Skip to content

Commit

Permalink
Adjust message queue error handling (openwallet-foundation#3170)
Browse files Browse the repository at this point in the history
Signed-off-by: jamshale <[email protected]>
  • Loading branch information
jamshale authored and darshilnb committed Sep 5, 2024
1 parent 7019b8c commit 3f3e07e
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 3f3e07e

Please sign in to comment.