summaryrefslogtreecommitdiffstats
path: root/components/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py
diff options
context:
space:
mode:
authorERIMROB <robertas.rimkus@est.tech>2020-06-19 13:09:44 +0100
committerERIMROB <robertas.rimkus@est.tech>2020-06-30 02:15:21 +0100
commitb80449b81a2deb3b6e2510a655de02f9375ef636 (patch)
treeee022a88ee287645c72f6716eb9c501b9cf06484 /components/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py
parent20637908b156aeff53d7607f88d655d0becc1f11 (diff)
[PMSH] Improve Failure Handling
Signed-off-by: ERIMROB <robertas.rimkus@est.tech> Change-Id: I15d338321957a293e9f444a10cf3bb06f4212f3e Issue-ID: DCAEGEN2-2157
Diffstat (limited to 'components/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py')
-rwxr-xr-xcomponents/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py11
1 files changed, 6 insertions, 5 deletions
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):