Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ POST v1.0.0 ] Adjust message queue error handling #3170

Merged
merged 3 commits into from
Aug 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading