From b80449b81a2deb3b6e2510a655de02f9375ef636 Mon Sep 17 00:00:00 2001 From: ERIMROB Date: Fri, 19 Jun 2020 13:09:44 +0100 Subject: [PMSH] Improve Failure Handling Signed-off-by: ERIMROB Change-Id: I15d338321957a293e9f444a10cf3bb06f4212f3e Issue-ID: DCAEGEN2-2157 --- .../pm-subscription-handler/pmsh_service/mod/pmsh_utils.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'components/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py') diff --git a/components/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py b/components/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py index fb6a5194..354d6b8d 100755 --- a/components/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py +++ b/components/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py @@ -200,12 +200,13 @@ class _MrPub(_DmaapMrClient): 'InvocationID': kwargs['invocation_id'], 'RequestID': kwargs['request_id'] } + logger.info(f'Attempting to publish event to {self.topic_url}') response = session.post(self.topic_url, headers=headers, auth=HTTPBasicAuth(self.aaf_id, self.aaf_pass), json=event_json, verify=False) response.raise_for_status() except Exception as e: - logger.debug(e) + logger.error(f'Failed to publish message to MR topic: {e}') raise def publish_subscription_event_data(self, subscription, xnf_name, app_conf): @@ -222,6 +223,7 @@ class _MrPub(_DmaapMrClient): self.publish_to_topic(subscription_event) except Exception as e: logger.debug(f'pmsh_utils.publish_subscription_event_data : {e}') + raise class _MrSub(_DmaapMrClient): @@ -241,9 +243,8 @@ class _MrSub(_DmaapMrClient): timeout: The request timeout value in mSec. Returns: - list[str]: the json response from DMaaP Message Router topic, else None. + list[str]: the json response from DMaaP Message Router topic. """ - topic_data = None try: session = requests.Session() headers = {'accept': 'application/json', 'content-type': 'application/json', @@ -256,10 +257,10 @@ class _MrSub(_DmaapMrClient): verify=False) response.raise_for_status() if response.ok: - topic_data = response.json() + return response.json() except Exception as e: logger.error(f'Failed to fetch message from MR: {e}') - return topic_data + raise class PeriodicTask(Timer): -- cgit 1.2.3-korg