From bc63700f7c6a3747cd7cb15453da45ac96d5a3fb Mon Sep 17 00:00:00 2001 From: Jorrit Schaap <schaap@astron.nl> Date: Mon, 2 Nov 2020 07:41:53 +0100 Subject: [PATCH] TMSS-421: added new MessageHandlerError. reject message if caught. --- LCS/Messaging/python/messaging/exceptions.py | 12 ++++++++++++ LCS/Messaging/python/messaging/messagebus.py | 3 +++ 2 files changed, 15 insertions(+) diff --git a/LCS/Messaging/python/messaging/exceptions.py b/LCS/Messaging/python/messaging/exceptions.py index 52e023d2145..003324cc41f 100644 --- a/LCS/Messaging/python/messaging/exceptions.py +++ b/LCS/Messaging/python/messaging/exceptions.py @@ -65,3 +65,15 @@ class MessagingTimeoutError(MessagingError, TimeoutError): """ pass + +class MessageHandlerError(MessagingError): + """ + raised upon handling a message + """ + pass + +class MessageHandlerUnknownSubjectError(MessageHandlerError): + """ + raised upon handling a message with an unknown subject + """ + pass diff --git a/LCS/Messaging/python/messaging/messagebus.py b/LCS/Messaging/python/messaging/messagebus.py index 734e5db18de..66feb5bad87 100644 --- a/LCS/Messaging/python/messaging/messagebus.py +++ b/LCS/Messaging/python/messaging/messagebus.py @@ -1570,6 +1570,9 @@ class BusListener: if isinstance(e, TimeoutError): logger.error("Handling of %s timed out: %s", lofar_msg, e) receiver.reject(lofar_msg, requeue=True) + elif isinstance(e, MessageHandlerError): + logger.error("Could not handle message %s: %s", lofar_msg, e) + receiver.reject(lofar_msg, requeue=False) else: logger.exception("Handling of %s failed. Rejecting message. Error: %s", lofar_msg, e) receiver.reject(lofar_msg, requeue=False) -- GitLab