Skip to content
Snippets Groups Projects
Commit 3ce2451d authored by Sathyanarayanan Saravanamuthu's avatar Sathyanarayanan Saravanamuthu
Browse files

Resolving review comments

parent 284b2428
No related branches found
No related tags found
Loading
...@@ -32,6 +32,8 @@ import org.slf4j.MDC; ...@@ -32,6 +32,8 @@ import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.concurrent.ConcurrentMap;
import java.util.Date;
@Component @Component
@ConditionalOnExpression("${azure.serviceBus.enabled:true} || ${azure.eventGridToServiceBus.enabled:true}") @ConditionalOnExpression("${azure.serviceBus.enabled:true} || ${azure.eventGridToServiceBus.enabled:true}")
...@@ -50,7 +52,7 @@ public class ProcessNotification { ...@@ -50,7 +52,7 @@ public class ProcessNotification {
public void performNotification(IMessage message, String subscriptionName) throws Exception { public void performNotification(IMessage message, String subscriptionName) throws Exception {
TelemetryClient telemetryClient = new TelemetryClient(); TelemetryClient telemetryClient = new TelemetryClient();
StopWatch stopWatch = new StopWatch(); StopWatch stopWatch = new StopWatch();
stopWatch.start(); stopWatch.start();
try { try {
NotificationContent notificationContent = requestBodyAdapter.extractNotificationContent(message, subscriptionName); NotificationContent notificationContent = requestBodyAdapter.extractNotificationContent(message, subscriptionName);
...@@ -58,13 +60,9 @@ public class ProcessNotification { ...@@ -58,13 +60,9 @@ public class ProcessNotification {
String dataPartitionId = notificationContent.getExtractAttributes().get(DpsHeaders.DATA_PARTITION_ID); String dataPartitionId = notificationContent.getExtractAttributes().get(DpsHeaders.DATA_PARTITION_ID);
String correlationId = notificationContent.getExtractAttributes().get(DpsHeaders.CORRELATION_ID); String correlationId = notificationContent.getExtractAttributes().get(DpsHeaders.CORRELATION_ID);
MDC.setContextMap(mdcContextMap.getContextMap(correlationId, dataPartitionId)); ConcurrentMap properties = telemetryClient.getContext().getProperties();
dpsHeaders.setThreadContext(dataPartitionId, correlationId); properties.put("correlation-id",correlationId);
properties.put("data-partition-id", dataPartitionId);
LOGGER.info("Notification process started for message with id: {}", message.getMessageId());
HttpResponse response = notificationHandler.notifySubscriber(notificationContent.getNotificationId(),
notificationContent.getData(), notificationContent.getExtractAttributes());
RequestTelemetry requestTelemetry = new RequestTelemetry( RequestTelemetry requestTelemetry = new RequestTelemetry(
"SBQueueRequest", "SBQueueRequest",
...@@ -72,8 +70,16 @@ public class ProcessNotification { ...@@ -72,8 +70,16 @@ public class ProcessNotification {
stopWatch.getTime(), stopWatch.getTime(),
"500", "500",
false); false);
requestTelemetry.setId(message.getMessageId()); requestTelemetry.setId(message.getMessageId());
MDC.setContextMap(mdcContextMap.getContextMap(correlationId, dataPartitionId));
dpsHeaders.setThreadContext(dataPartitionId, correlationId);
LOGGER.info("Notification process started for message with id: {}", message.getMessageId());
HttpResponse response = notificationHandler.notifySubscriber(notificationContent.getNotificationId(),
notificationContent.getData(), notificationContent.getExtractAttributes());
if (!response.isSuccessCode()) { if (!response.isSuccessCode()) {
telemetryClient.trackRequest(requestTelemetry); telemetryClient.trackRequest(requestTelemetry);
throw new Exception(NOT_ACKNOWLEDGE); throw new Exception(NOT_ACKNOWLEDGE);
...@@ -83,11 +89,12 @@ public class ProcessNotification { ...@@ -83,11 +89,12 @@ public class ProcessNotification {
telemetryClient.trackRequest(requestTelemetry); telemetryClient.trackRequest(requestTelemetry);
} }
} catch (Exception e) { } catch (Exception e) {
LOGGER.error(String.format("An error occurred performing Notification for message with ID: ", message.getMessageId()), e); LOGGER.error(String.format("An error occurred performing Notification for message with ID: ", message.getMessageId()), e);
throw e; throw e;
} finally { } finally {
ThreadScopeContextHolder.getContext().clear(); ThreadScopeContextHolder.getContext().clear();
MDC.clear(); MDC.clear();
stopWatch.stop();
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment