From 81a453b71a98d0292f347807e1ad5701e6382f09 Mon Sep 17 00:00:00 2001 From: Abdullah Habes <33485177+AHabes@users.noreply.github.com> Date: Tue, 17 Oct 2023 14:46:43 -0400 Subject: [PATCH 1/4] Fix tomcat-embed-core 10.1.13 dependency (#127) --- service/application/pom.xml | 2 +- service/plugin/pom.xml | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/service/application/pom.xml b/service/application/pom.xml index 0073c273..0860632a 100644 --- a/service/application/pom.xml +++ b/service/application/pom.xml @@ -43,7 +43,7 @@ org.apache.tomcat.embed tomcat-embed-core - 10.1.13 + 10.1.14 org.springframework.boot diff --git a/service/plugin/pom.xml b/service/plugin/pom.xml index 43bdc840..5160799c 100644 --- a/service/plugin/pom.xml +++ b/service/plugin/pom.xml @@ -37,7 +37,7 @@ org.apache.tomcat.embed tomcat-embed-core - 10.1.13 + 10.1.14 org.springframework.boot @@ -108,11 +108,6 @@ netty-codec-socks 4.1.100.Final - - io.netty - netty-handler - 4.1.100.Final - org.apache.camel.springboot camel-spring-boot-starter From cff50bc567c9077b1c27717ed56b2c8da12c8b8a Mon Sep 17 00:00:00 2001 From: Greg Meldrum Date: Tue, 17 Oct 2023 21:08:31 -0400 Subject: [PATCH 2/4] DATAGO-63031: Fix logging of traceId, actorId and orgId so it's consistent between EMA and EP (#125) --- service/application/pom.xml | 30 +++++++++++++++---- .../messages/ScanDataImportMessage.java | 4 +-- .../ep/common/messages/ScanDataMessage.java | 7 ++--- .../messages/ScanDataStatusMessage.java | 7 ++--- .../ep/common/messages/ScanLogMessage.java | 7 ++--- .../ep/common/messages/ScanStatusMessage.java | 7 ++--- .../agent/logging/StreamingAppender.java | 7 +++-- ...anDataImportParseMetaInfFileProcessor.java | 2 ++ .../agent/processor/ScanDataProcessor.java | 3 +- .../agent/processor/ScanLogsProcessor.java | 5 ++-- .../processor/ScanStatusOverAllProcessor.java | 3 +- .../ScanStatusPerRouteProcessor.java | 4 ++- .../ScanTypeDescendentsProcessorImpl.java | 6 ++-- .../repository/model/scan/ScanEntity.java | 17 ++++++----- .../agent/scanManager/ScanManager.java | 4 ++- .../scanManager/model/ScanRequestBO.java | 3 ++ .../rest/DataImportControllerImpl.java | 10 +++++-- .../management/agent/service/ScanService.java | 28 ++++++++++------- .../subscriber/ScanCommandMessageHandler.java | 1 + .../subscriber/SolaceMessageHandler.java | 4 ++- .../src/main/resources/logback-spring.xml | 2 +- .../ScanLogsPublisherRouteBuilderTests.java | 1 + ...tatusMarkerAndLoggerRouteBuilderTests.java | 1 + .../processor/ScanDataProcessorTests.java | 1 + .../ScanStatusOverAllProcessorTests.java | 1 + .../ScanStatusPerRouteProcessorTests.java | 1 + .../agent/scanManager/ScanManagerTest.java | 9 ++++-- .../mapper/ScanRequestMapperTest.java | 4 ++- .../rest/DataImportControllerTests.java | 13 +++++--- .../scanManager/rest/EMAControllerTest.java | 3 ++ .../agent/service/ScanServiceTests.java | 7 +++-- .../plugin/constants/RouteConstants.java | 4 ++- .../agent/plugin/mop/MOPMessage.java | 3 ++ .../processor/logging/MDCProcessor.java | 3 ++ ...ScanStatusMarkerAndLoggerRouteBuilder.java | 18 +++++++---- 35 files changed, 155 insertions(+), 75 deletions(-) diff --git a/service/application/pom.xml b/service/application/pom.xml index 0860632a..a716b539 100644 --- a/service/application/pom.xml +++ b/service/application/pom.xml @@ -17,7 +17,6 @@ 1.6.11 2.0 - 3.1.5 1.1.1 3.0.10 3.5.0 @@ -63,11 +62,6 @@ org.springframework.boot spring-boot-starter-data-jpa - - org.springframework.cloud - spring-cloud-starter-sleuth - ${spring-cloud-starter-sleuth.version} - org.springframework.security spring-security-rsa @@ -283,6 +277,30 @@ 1.1.2-SNAPSHOT + + io.micrometer + micrometer-tracing-bridge-brave + + + + io.micrometer + context-propagation + 1.0.3 + + + io.micrometer + micrometer-observation + + + io.micrometer + micrometer-observation-test + test + + + org.springframework.boot + spring-boot-starter-actuator + + org.hamcrest diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataImportMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataImportMessage.java index de49843c..f7f7e2a8 100644 --- a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataImportMessage.java +++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataImportMessage.java @@ -16,8 +16,6 @@ public class ScanDataImportMessage extends MOPMessage { String scanId; - String traceId; - String messagingServiceId; String runtimeAgentId; @@ -37,10 +35,10 @@ public ScanDataImportMessage(String orgId, String scanId, String traceId, String this.orgId = orgId; this.scanId = scanId; - this.traceId = traceId; this.messagingServiceId = messagingServiceId; this.runtimeAgentId = runtimeAgentId; this.scanTypes = scanTypes; + setTraceId(traceId); } @Override diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataMessage.java index 08ccb392..0f796a02 100644 --- a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataMessage.java +++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataMessage.java @@ -12,15 +12,13 @@ public class ScanDataMessage extends MOPMessage { String scanId; - String traceId; - String scanType; String data; private String timestamp; - public ScanDataMessage(String orgId, String scanId, String traceId, String scanType, String data, String timestamp) { + public ScanDataMessage(String orgId, String scanId, String traceId, String actorId, String scanType, String data, String timestamp) { super(); withMessageType(MOPMessageType.generic) .withProtocol(MOPProtocol.scanData) @@ -29,10 +27,11 @@ public ScanDataMessage(String orgId, String scanId, String traceId, String scanT this.orgId = orgId; this.scanId = scanId; - this.traceId = traceId; this.scanType = scanType; this.data = data; this.timestamp = timestamp; + setTraceId(traceId); + setActorId(actorId); } @Override diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataStatusMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataStatusMessage.java index e73b04e6..c607afa1 100644 --- a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataStatusMessage.java +++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataStatusMessage.java @@ -16,15 +16,13 @@ public class ScanDataStatusMessage extends MOPMessage { String scanId; - String traceId; - String status; String description; String scanType; - public ScanDataStatusMessage(String orgId, String scanId, String traceId, String status, String description, String scanType) { + public ScanDataStatusMessage(String orgId, String scanId, String traceId, String actorId, String status, String description, String scanType) { super(); withMessageType(MOPMessageType.generic) .withProtocol(MOPProtocol.scanDataControl) @@ -33,10 +31,11 @@ public ScanDataStatusMessage(String orgId, String scanId, String traceId, String this.orgId = orgId; this.scanId = scanId; - this.traceId = traceId; this.status = status; this.description = description; this.scanType = scanType; + setTraceId(traceId); + setActorId(actorId); } @Override diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanLogMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanLogMessage.java index f4aec38c..63c192e2 100644 --- a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanLogMessage.java +++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanLogMessage.java @@ -12,15 +12,13 @@ public class ScanLogMessage extends MOPMessage { String scanId; - String traceId; - String level; String log; Long timestamp; - public ScanLogMessage(String orgId, String scanId, String traceId, String level, String log, Long timestamp) { + public ScanLogMessage(String orgId, String scanId, String traceId, String actorId, String level, String log, Long timestamp) { super(); withMessageType(MOPMessageType.generic) .withProtocol(MOPProtocol.scanDataControl) @@ -29,10 +27,11 @@ public ScanLogMessage(String orgId, String scanId, String traceId, String level, this.orgId = orgId; this.scanId = scanId; - this.traceId = traceId; this.level = level; this.log = log; this.timestamp = timestamp; + setTraceId(traceId); + setActorId(actorId); } @Override diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanStatusMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanStatusMessage.java index c4d75d8f..79d9496c 100644 --- a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanStatusMessage.java +++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanStatusMessage.java @@ -18,15 +18,13 @@ public class ScanStatusMessage extends MOPMessage { String scanId; - String traceId; - String status; String description; private List scanTypes; - public ScanStatusMessage(String orgId, String scanId, String traceId, String status, String description, List scanTypes) { + public ScanStatusMessage(String orgId, String scanId, String traceId, String actorId, String status, String description, List scanTypes) { super(); withMessageType(MOPMessageType.generic) .withProtocol(MOPProtocol.scanDataControl) @@ -35,10 +33,11 @@ public ScanStatusMessage(String orgId, String scanId, String traceId, String sta this.orgId = orgId; this.scanId = scanId; - this.traceId = traceId; this.status = status; this.description = description; this.scanTypes = scanTypes; + setTraceId(traceId); + setActorId(actorId); } @Override diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/logging/StreamingAppender.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/logging/StreamingAppender.java index c9b8dee3..da30ca9e 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/logging/StreamingAppender.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/logging/StreamingAppender.java @@ -2,11 +2,11 @@ import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.AppenderBase; -import com.solace.maas.ep.event.management.agent.repository.model.route.RouteEntity; import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants; import com.solace.maas.ep.event.management.agent.plugin.manager.loader.PluginLoader; import com.solace.maas.ep.event.management.agent.plugin.route.RouteBundle; import com.solace.maas.ep.event.management.agent.plugin.route.handler.base.MessagingServiceRouteDelegate; +import com.solace.maas.ep.event.management.agent.repository.model.route.RouteEntity; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.extern.slf4j.Slf4j; @@ -30,6 +30,7 @@ protected void append(ILoggingEvent event) { sendLogsAsync(event, event.getMDCPropertyMap().get(RouteConstants.SCAN_ID), event.getMDCPropertyMap().get(RouteConstants.TRACE_ID), + event.getMDCPropertyMap().get(RouteConstants.ACTOR_ID), event.getMDCPropertyMap().get(RouteConstants.SCAN_TYPE), event.getMDCPropertyMap().get(RouteConstants.SCHEDULE_ID), event.getMDCPropertyMap().get(RouteConstants.MESSAGING_SERVICE_ID)); @@ -37,13 +38,15 @@ protected void append(ILoggingEvent event) { } } - public void sendLogsAsync(ILoggingEvent event, String scanId, String traceId, String scanType, String groupId, String messagingServiceId) { + public void sendLogsAsync(ILoggingEvent event, String scanId, String traceId, String actorId, + String scanType, String groupId, String messagingServiceId) { RouteEntity route = creatLoggingRoute(scanType, messagingServiceId); producerTemplate.asyncSend(route.getId(), exchange -> { // Need to set headers to let the Route have access to the Scan ID, Group ID, and Messaging Service ID. exchange.getIn().setHeader(RouteConstants.SCAN_ID, scanId); exchange.getIn().setHeader(RouteConstants.TRACE_ID, traceId); + exchange.getIn().setHeader(RouteConstants.ACTOR_ID, actorId); exchange.getIn().setHeader(RouteConstants.SCAN_TYPE, scanType); exchange.getIn().setHeader(RouteConstants.SCHEDULE_ID, groupId); exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, messagingServiceId); diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportParseMetaInfFileProcessor.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportParseMetaInfFileProcessor.java index 9516d2c1..dd574238 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportParseMetaInfFileProcessor.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataImportParseMetaInfFileProcessor.java @@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.camel.Exchange; import org.apache.camel.Processor; +import org.slf4j.MDC; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.stereotype.Component; @@ -23,6 +24,7 @@ public class ScanDataImportParseMetaInfFileProcessor implements Processor { public void process(Exchange exchange) throws Exception { MetaInfFileBO metaInfFileBO = exchange.getIn().getBody(MetaInfFileBO.class); String traceId = (String) exchange.getProperty(TRACE_ID); + MDC.put(TRACE_ID, traceId); exchange.getIn().setHeader(RouteConstants.SCAN_ID, metaInfFileBO.getScanId()); exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, metaInfFileBO.getMessagingServiceId()); diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataProcessor.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataProcessor.java index 6ed3d73d..7531f34d 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataProcessor.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanDataProcessor.java @@ -46,10 +46,11 @@ public void process(Exchange exchange) throws Exception { String messagingServiceId = (String) properties.get(RouteConstants.MESSAGING_SERVICE_ID); String scanId = (String) properties.get(RouteConstants.SCAN_ID); String traceId = (String) properties.get(RouteConstants.TRACE_ID); + String actorId = (String) properties.get(RouteConstants.ACTOR_ID); String scanType = (String) properties.get(RouteConstants.SCAN_TYPE); Boolean isImportOp = (Boolean) properties.get(RouteConstants.IS_DATA_IMPORT); - ScanDataMessage scanDataMessage = new ScanDataMessage(orgId, scanId, traceId, scanType, body, Instant.now().toString()); + ScanDataMessage scanDataMessage = new ScanDataMessage(orgId, scanId, traceId, actorId, scanType, body, Instant.now().toString()); topicDetails.put("orgId", orgId); topicDetails.put("runtimeAgentId", runtimeAgentId); diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanLogsProcessor.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanLogsProcessor.java index 7148f44c..456b8c6b 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanLogsProcessor.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanLogsProcessor.java @@ -3,8 +3,8 @@ import ch.qos.logback.classic.spi.ILoggingEvent; import com.solace.maas.ep.common.messages.ScanLogMessage; import com.solace.maas.ep.event.management.agent.config.eventPortal.EventPortalProperties; -import com.solace.maas.ep.event.management.agent.publisher.ScanLogsPublisher; import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants; +import com.solace.maas.ep.event.management.agent.publisher.ScanLogsPublisher; import lombok.extern.slf4j.Slf4j; import org.apache.camel.Exchange; import org.apache.camel.Processor; @@ -42,9 +42,10 @@ public void process(Exchange exchange) throws Exception { ILoggingEvent event = (ILoggingEvent) exchange.getIn().getBody(); String scanId = (String) properties.get(RouteConstants.SCAN_ID); String traceId = (String) properties.get(RouteConstants.TRACE_ID); + String actorId = (String) properties.get(RouteConstants.ACTOR_ID); String messagingServiceId = (String) properties.get(RouteConstants.MESSAGING_SERVICE_ID); - ScanLogMessage logDataMessage = new ScanLogMessage(orgId, scanId, traceId, event.getLevel().toString(), + ScanLogMessage logDataMessage = new ScanLogMessage(orgId, scanId, traceId, actorId, event.getLevel().toString(), String.format("%s%s", event.getFormattedMessage(), "\n"), event.getTimeStamp()); topicDetails.put("orgId", orgId); diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusOverAllProcessor.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusOverAllProcessor.java index cb26d325..53fb4fed 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusOverAllProcessor.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusOverAllProcessor.java @@ -41,6 +41,7 @@ public void process(Exchange exchange) throws Exception { String messagingServiceId = (String) properties.get(RouteConstants.MESSAGING_SERVICE_ID); String scanId = (String) properties.get(RouteConstants.SCAN_ID); String traceId = (String) properties.get(RouteConstants.TRACE_ID); + String actorId = (String) properties.get(RouteConstants.ACTOR_ID); ScanStatus status = (ScanStatus) properties.get(RouteConstants.SCAN_STATUS); String description = (String) properties.get(RouteConstants.SCAN_STATUS_DESC); @@ -54,7 +55,7 @@ public void process(Exchange exchange) throws Exception { topicDetails.put("scanType", scanType); topicDetails.put("status", status.name()); - ScanStatusMessage generalStatusMessage = new ScanStatusMessage(orgId, scanId, traceId, status.name(), description, scanTypes); + ScanStatusMessage generalStatusMessage = new ScanStatusMessage(orgId, scanId, traceId, actorId, status.name(), description, scanTypes); exchange.getIn().setHeader(RouteConstants.GENERAL_STATUS_MESSAGE, generalStatusMessage); exchange.getIn().setHeader(RouteConstants.TOPIC_DETAILS, topicDetails); diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusPerRouteProcessor.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusPerRouteProcessor.java index 675d2aa7..e96ddc8a 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusPerRouteProcessor.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusPerRouteProcessor.java @@ -38,6 +38,7 @@ public void process(Exchange exchange) throws Exception { String messagingServiceId = (String) properties.get(RouteConstants.MESSAGING_SERVICE_ID); String scanId = (String) properties.get(RouteConstants.SCAN_ID); String traceId = (String) properties.get(RouteConstants.TRACE_ID); + String actorId = (String) properties.get(RouteConstants.ACTOR_ID); String scanType = (String) properties.get(RouteConstants.SCAN_TYPE); ScanStatus status = (ScanStatus) properties.get(RouteConstants.SCAN_STATUS); String description = (String) properties.get(RouteConstants.SCAN_STATUS_DESC); @@ -49,7 +50,8 @@ public void process(Exchange exchange) throws Exception { topicDetails.put("status", status.name()); topicDetails.put("scanDataType", scanType); - ScanDataStatusMessage scanDataStatusMessage = new ScanDataStatusMessage(orgId, scanId, traceId, status.name(), description, scanType); + ScanDataStatusMessage scanDataStatusMessage = new ScanDataStatusMessage(orgId, scanId, traceId, actorId, + status.name(), description, scanType); exchange.getIn().setHeader(RouteConstants.SCAN_DATA_STATUS_MESSAGE, scanDataStatusMessage); exchange.getIn().setHeader(RouteConstants.TOPIC_DETAILS, topicDetails); diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanTypeDescendentsProcessorImpl.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanTypeDescendentsProcessorImpl.java index 17924ceb..69c8a54c 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanTypeDescendentsProcessorImpl.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/ScanTypeDescendentsProcessorImpl.java @@ -4,11 +4,11 @@ import com.solace.maas.ep.event.management.agent.plugin.processor.ScanTypeDescendentsProcessor; import com.solace.maas.ep.event.management.agent.repository.model.scan.ScanRecipientHierarchyEntity; import com.solace.maas.ep.event.management.agent.repository.scan.ScanRecipientHierarchyRepository; +import jakarta.transaction.Transactional; import lombok.extern.slf4j.Slf4j; import org.apache.camel.Exchange; import org.springframework.stereotype.Component; -import jakarta.transaction.Transactional; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -33,6 +33,7 @@ public void process(Exchange exchange) throws Exception { String scanId = (String) properties.get(RouteConstants.SCAN_ID); String traceId = (String) properties.get(RouteConstants.TRACE_ID); + String actorId = (String) properties.get(RouteConstants.ACTOR_ID); String scanType = (String) properties.get(RouteConstants.SCAN_TYPE); boolean isEmptyScanTypes = (boolean) properties.get(RouteConstants.IS_EMPTY_SCAN_TYPES); @@ -43,7 +44,8 @@ public void process(Exchange exchange) throws Exception { if (isEmptyScanTypes) { allDescendentScanTypes.forEach(type -> - log.info("Scan request [{}], trace ID [{}]: Encountered an empty scan type [{}].", scanId, traceId, type)); + log.info("Scan request [{}], trace ID [{}], actor ID [{}]: Encountered an empty scan type [{}].", + scanId, traceId, actorId, type)); } exchange.getIn().setHeader(RouteConstants.SCAN_TYPE, allDescendentScanTypes); diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/repository/model/scan/ScanEntity.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/repository/model/scan/ScanEntity.java index 6983c5aa..695ae9e1 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/repository/model/scan/ScanEntity.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/repository/model/scan/ScanEntity.java @@ -4,13 +4,6 @@ import com.solace.maas.ep.event.management.agent.repository.model.file.DataCollectionFileEntity; import com.solace.maas.ep.event.management.agent.repository.model.mesagingservice.MessagingServiceEntity; import com.solace.maas.ep.event.management.agent.repository.model.route.RouteEntity; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.hibernate.annotations.CreationTimestamp; -import org.springframework.data.jpa.domain.support.AuditingEntityListener; - import jakarta.persistence.CascadeType; import jakarta.persistence.Column; import jakarta.persistence.Entity; @@ -22,6 +15,13 @@ import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; import jakarta.persistence.Table; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.hibernate.annotations.CreationTimestamp; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + import java.io.Serializable; import java.time.Instant; import java.util.List; @@ -45,6 +45,9 @@ public class ScanEntity implements Serializable { @Column(name = "TRACE_ID") private String traceId; + @Column(name = "ACTOR_ID") + private String actorId; + @OneToMany(mappedBy = "scan", fetch = FetchType.LAZY, cascade = CascadeType.MERGE) private List scanTypes; diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/ScanManager.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/ScanManager.java index facb517d..4f5225c2 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/ScanManager.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/ScanManager.java @@ -45,10 +45,12 @@ public String scan(ScanRequestBO scanRequestBO) { String messagingServiceId = scanRequestBO.getMessagingServiceId(); String scanId = scanRequestBO.getScanId(); String traceId = scanRequestBO.getTraceId(); + String actorId = scanRequestBO.getActorId(); String groupId = UUID.randomUUID().toString(); MDC.put(RouteConstants.SCAN_ID, scanId); MDC.put(RouteConstants.TRACE_ID, traceId); + MDC.put(RouteConstants.ACTOR_ID, actorId); MDC.put(RouteConstants.SCHEDULE_ID, groupId); MDC.put(RouteConstants.MESSAGING_SERVICE_ID, messagingServiceId); @@ -97,7 +99,7 @@ public String scan(ScanRequestBO scanRequestBO) { ) .collect(Collectors.toList()).stream().flatMap(List::stream).collect(Collectors.toList()); - return scanService.singleScan(routes, groupId, scanId, traceId, messagingServiceEntity, runtimeAgentId); + return scanService.singleScan(routes, groupId, scanId, traceId, actorId, messagingServiceEntity, runtimeAgentId); } private MessagingServiceEntity retrieveMessagingServiceEntity(String messagingServiceId) { diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/model/ScanRequestBO.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/model/ScanRequestBO.java index ab35eacf..cae964a5 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/model/ScanRequestBO.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/model/ScanRequestBO.java @@ -23,6 +23,8 @@ public class ScanRequestBO extends AbstractBaseBO { private String traceId; + private String actorId; + private List scanTypes; private List destinations; @@ -32,6 +34,7 @@ public String toString() { return "{ messaging service id:[" + messagingServiceId + ']' + ", scan id: [" + scanId + ']' + ", trace id: " + traceId + + ", actor id: " + actorId + ", scan types: " + scanTypes + ", destinations: " + destinations + " }"; diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerImpl.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerImpl.java index b9d525fc..0fa89d83 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerImpl.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerImpl.java @@ -4,9 +4,9 @@ import com.solace.maas.ep.event.management.agent.scanManager.model.ImportRequestBO; import com.solace.maas.ep.event.management.agent.scanManager.model.ZipRequestBO; import com.solace.maas.ep.event.management.agent.service.ImportService; +import io.micrometer.tracing.Tracer; import io.swagger.v3.oas.annotations.Parameter; import lombok.extern.slf4j.Slf4j; -import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.InputStreamResource; import org.springframework.http.HttpHeaders; @@ -24,6 +24,7 @@ import org.springframework.web.multipart.MultipartFile; import java.io.InputStream; +import java.util.Objects; @Slf4j @Validated @@ -34,9 +35,12 @@ public class DataImportControllerImpl implements DataImportController { private final ImportService importService; + private final Tracer trace; + @Autowired - public DataImportControllerImpl(ImportService importService) { + public DataImportControllerImpl(ImportService importService, Tracer trace) { this.importService = importService; + this.trace = trace; } @Override @@ -44,7 +48,7 @@ public DataImportControllerImpl(ImportService importService) { public ResponseEntity read(@Parameter(description = "The scan data zip file to be imported.") @RequestPart("file") final MultipartFile file) { try { - String traceId = MDC.get("traceId"); + String traceId = Objects.requireNonNull(trace.currentSpan()).context().traceId(); ImportRequestBO importRequestBO = ImportRequestBO.builder() .dataFile(file) .traceId(traceId) diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ScanService.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ScanService.java index 5ce50e18..53a8f5fe 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ScanService.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ScanService.java @@ -16,8 +16,8 @@ import com.solace.maas.ep.event.management.agent.repository.model.scan.ScanTypeEntity; import com.solace.maas.ep.event.management.agent.repository.scan.ScanRecipientHierarchyRepository; import com.solace.maas.ep.event.management.agent.repository.scan.ScanRepository; -import com.solace.maas.ep.event.management.agent.repository.scan.ScanTypeRepository; import com.solace.maas.ep.event.management.agent.repository.scan.ScanStatusRepository; +import com.solace.maas.ep.event.management.agent.repository.scan.ScanTypeRepository; import com.solace.maas.ep.event.management.agent.scanManager.model.ScanItemBO; import com.solace.maas.ep.event.management.agent.scanManager.model.ScanTypeBO; import com.solace.maas.ep.event.management.agent.util.IDGenerator; @@ -139,7 +139,7 @@ public ScanService(ScanRepository repository, * @param routeBundles - see description above * @return The id of the scan. */ - public String singleScan(List routeBundles, String groupId, String scanId, String traceId, + public String singleScan(List routeBundles, String groupId, String scanId, String traceId, String actorId, MessagingServiceEntity messagingServiceEntity, String runtimeAgentId) { log.info("Scan request [{}], trace ID [{}]: Starting a single scan.", scanId, traceId); @@ -153,14 +153,14 @@ public String singleScan(List routeBundles, String groupId, String log.info("Scan request [{}], trace ID [{}]: Total of {} scan types to be retrieved: [{}].", scanId, traceId, scanTypes.size(), StringUtils.join(scanTypes, ", ")); - sendScanStatus(groupId, scanId, traceId, routeBundles.stream().findFirst().orElseThrow().getMessagingServiceId(), + sendScanStatus(groupId, scanId, traceId, actorId, routeBundles.stream().findFirst().orElseThrow().getMessagingServiceId(), StringUtils.join(scanTypes, ","), ScanStatus.IN_PROGRESS); log.trace("RouteBundles to be processed: {}", routeBundles); String scanEntityId = Objects.requireNonNullElseGet(scanId, () -> UUID.randomUUID().toString()); - ScanEntity returnedScanEntity = setupScan(scanEntityId, traceId, messagingServiceEntity, runtimeAgentId); + ScanEntity returnedScanEntity = setupScan(scanEntityId, traceId, actorId, messagingServiceEntity, runtimeAgentId); for (RouteBundle routeBundle : routeBundles) { log.trace("Processing RouteBundles: {}", routeBundle); @@ -170,15 +170,15 @@ public String singleScan(List routeBundles, String groupId, String updateScan(route, routeBundle, returnedScanEntity); - scanAsync(groupId, scanEntityId, traceId, route, routeBundle.getMessagingServiceId()); + scanAsync(groupId, scanEntityId, traceId, actorId, route, routeBundle.getMessagingServiceId()); } return scanId; } @Transactional - protected ScanEntity setupScan(String scanId, String traceId, MessagingServiceEntity messagingServiceEntity, String emaId) { - return saveScanEntity(scanId, traceId, messagingServiceEntity, emaId); + protected ScanEntity setupScan(String scanId, String traceId, String actorId, MessagingServiceEntity messagingServiceEntity, String emaId) { + return saveScanEntity(scanId, traceId, actorId, messagingServiceEntity, emaId); } @Transactional @@ -212,10 +212,12 @@ protected void updateScan(RouteEntity route, RouteBundle routeBundle, ScanEntity setupRecipientsForScan(scanEntity, routeBundle); } - private ScanEntity saveScanEntity(String scanId, String traceId, MessagingServiceEntity messagingServiceEntity, String emaId) { + private ScanEntity saveScanEntity(String scanId, String traceId, String actorId, + MessagingServiceEntity messagingServiceEntity, String emaId) { ScanEntity scan = ScanEntity.builder() .id(scanId) .traceId(traceId) + .actorId(actorId) .messagingService(messagingServiceEntity) .emaId(emaId) .build(); @@ -247,6 +249,7 @@ private void setScanStatus(ScanTypeEntity scanType) { scanStatusRepository.save(scanStatus); } + protected void setupRecipientsForScan(ScanEntity scanEntity, RouteBundle routeBundle) { for (RouteBundle recipient : routeBundle.getRecipients()) { @@ -269,12 +272,13 @@ public Optional findById(String scanId) { * @param scanTypes The scan types included in the scan request. * @param status The status of scan. */ - public void sendScanStatus(String groupId, String scanId, String traceId, String messagingServiceId, String scanTypes, + public void sendScanStatus(String groupId, String scanId, String traceId, String actorId, String messagingServiceId, String scanTypes, ScanStatus status) { producerTemplate.send("direct:overallScanStatusPublisher?block=false&failIfNoConsumers=false", exchange -> { exchange.getIn().setHeader(RouteConstants.SCHEDULE_ID, groupId); exchange.getIn().setHeader(RouteConstants.SCAN_ID, scanId); exchange.getIn().setHeader(RouteConstants.TRACE_ID, traceId); + exchange.getIn().setHeader(RouteConstants.ACTOR_ID, actorId); exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, messagingServiceId); exchange.getIn().setHeader(RouteConstants.SCAN_TYPE, scanTypes); exchange.getIn().setHeader(RouteConstants.SCAN_STATUS, status); @@ -282,12 +286,14 @@ public void sendScanStatus(String groupId, String scanId, String traceId, String }); } - protected CompletableFuture scanAsync(String groupId, String scanId, String traceId, RouteEntity route, String messagingServiceId) { + protected CompletableFuture scanAsync(String groupId, String scanId, String traceId, String actorId, + RouteEntity route, String messagingServiceId) { return producerTemplate.asyncSend("seda:" + route.getId(), exchange -> { // Need to set headers to let the Route have access to the Scan ID, Group ID, and Messaging Service ID. exchange.getIn().setHeader(RouteConstants.SCHEDULE_ID, groupId); exchange.getIn().setHeader(RouteConstants.SCAN_ID, scanId); exchange.getIn().setHeader(RouteConstants.TRACE_ID, traceId); + exchange.getIn().setHeader(RouteConstants.ACTOR_ID, actorId); exchange.getIn().setHeader(RouteConstants.MESSAGING_SERVICE_ID, messagingServiceId); exchange.getIn().setHeader(RouteConstants.SCAN_STATUS_DESC, ""); @@ -301,7 +307,9 @@ protected CompletableFuture scanAsync(String groupId, String scanId, S MDC.put(RouteConstants.SCHEDULE_ID, groupId); MDC.put(RouteConstants.SCAN_ID, scanId); MDC.put(RouteConstants.TRACE_ID, traceId); + MDC.put(RouteConstants.ACTOR_ID, actorId); MDC.put(RouteConstants.MESSAGING_SERVICE_ID, messagingServiceId); + }).whenComplete((exchange, exception) -> { if (exception != null) { log.error("Exception occurred while executing route {} for scan request: {}.", route.getId(), scanId, exception); diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java index 0acb3a99..ecef322d 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java @@ -57,6 +57,7 @@ public void receiveMessage(String destinationName, ScanCommandMessage message) { .messagingServiceId(message.getMessagingServiceId()) .scanId(!StringUtils.isEmpty(message.getScanId()) ? message.getScanId() : UUID.randomUUID().toString()) .traceId(message.getTraceId()) + .actorId(message.getActorId()) .scanTypes(entityTypes) .destinations(scanRequestDestinations) .build(); diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/SolaceMessageHandler.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/SolaceMessageHandler.java index 79105bfb..6d323c25 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/SolaceMessageHandler.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/SolaceMessageHandler.java @@ -69,15 +69,17 @@ public void onMessage(InboundMessage inboundMessage) { String receivedClassName = messageClass.getSimpleName(); - if ("ScanCommandMessage" .equals(receivedClassName) || "ScanDataImportMessage" .equals(receivedClassName)) { + if ("ScanCommandMessage".equals(receivedClassName) || "ScanDataImportMessage".equals(receivedClassName)) { Map map = objectMapper.readValue(messageAsString, Map.class); String scanId = (String) map.get("scanId"); String traceId = (String) map.get("traceId"); + String actorId = (String) map.get("actorId"); String messagingServiceId = (String) map.get("messagingServiceId"); MDC.clear(); MDC.put(RouteConstants.SCAN_ID, scanId); MDC.put(RouteConstants.TRACE_ID, traceId); + MDC.put(RouteConstants.ACTOR_ID, actorId); MDC.put(RouteConstants.MESSAGING_SERVICE_ID, messagingServiceId); } diff --git a/service/application/src/main/resources/logback-spring.xml b/service/application/src/main/resources/logback-spring.xml index 8714e1d3..0f3f960e 100644 --- a/service/application/src/main/resources/logback-spring.xml +++ b/service/application/src/main/resources/logback-spring.xml @@ -1,7 +1,7 @@ - + diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanLogsPublisherRouteBuilderTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanLogsPublisherRouteBuilderTests.java index 5328bb75..1ea40e1f 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanLogsPublisherRouteBuilderTests.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanLogsPublisherRouteBuilderTests.java @@ -89,6 +89,7 @@ public void testScanLogMessageMOPProtocol() { "orgId", "scanId", "traceId", + "actorId", "level", "log", Instant.now().toEpochMilli()); diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanStatusMarkerAndLoggerRouteBuilderTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanStatusMarkerAndLoggerRouteBuilderTests.java index 6a5fa593..34b1debe 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanStatusMarkerAndLoggerRouteBuilderTests.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanStatusMarkerAndLoggerRouteBuilderTests.java @@ -59,6 +59,7 @@ public void testMarkRouteScanStatusInProgress() { exchange.getIn().setHeader(RouteConstants.SCAN_TYPE, "queueListing"); exchange.getIn().setHeader(RouteConstants.SCAN_STATUS, ScanStatus.IN_PROGRESS); exchange.getIn().setHeader(RouteConstants.TRACE_ID, "1234"); + exchange.getIn().setHeader(RouteConstants.ACTOR_ID, "4321"); AdviceWith.adviceWith(camelContext, "markRouteScanStatusInProgress", route -> { diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanDataProcessorTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanDataProcessorTests.java index 22a39761..43305994 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanDataProcessorTests.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanDataProcessorTests.java @@ -64,6 +64,7 @@ public void testScanMessageMOPProtocol() { "orgId", "scanId", "traceId", + "actorId", "scanType", " body", Instant.now().toString()); diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusOverAllProcessorTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusOverAllProcessorTests.java index 5a9087dd..5251f2c4 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusOverAllProcessorTests.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusOverAllProcessorTests.java @@ -69,6 +69,7 @@ public void testScanStatusMessageProtocol() { null, "scan1", "traceId", + "actorId", ScanStatus.IN_PROGRESS.name(), "description", List.of("scanTypes")); diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusPerRouteProcessorTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusPerRouteProcessorTests.java index e829412f..734ed6db 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusPerRouteProcessorTests.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/processor/ScanStatusPerRouteProcessorTests.java @@ -69,6 +69,7 @@ public void testScanDataStatusMessageMOPProtocol() { null, "scan1", "traceId", + "actorId", ScanStatus.IN_PROGRESS.name(), "description", "queueListing"); diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/ScanManagerTest.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/ScanManagerTest.java index 281dc5e5..e97d51b2 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/ScanManagerTest.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/ScanManagerTest.java @@ -62,7 +62,7 @@ void testScanManagerExceptions() { when(messagingServiceDelegateService.getMessagingServiceById("id")) .thenReturn(messagingServiceEntity); - when(scanService.singleScan(List.of(), "groupId", "scanId", "traceId", + when(scanService.singleScan(List.of(), "groupId", "scanId", "traceId", "actorId", mock(MessagingServiceEntity.class), "runtimeAgent1")) .thenReturn(Mockito.anyString()); @@ -70,6 +70,7 @@ void testScanManagerExceptions() { "id", "scanId", "traceId", + "actorId", List.of("topics"), List.of()); @@ -79,6 +80,7 @@ void testScanManagerExceptions() { "id", "scanId", "traceId", + "actorId", List.of("TEST_SCAN_1"), List.of()); @@ -88,6 +90,7 @@ void testScanManagerExceptions() { "id", "scanId", "traceId", + "actorId", List.of("TEST_SCAN_2"), List.of()); @@ -101,7 +104,7 @@ void testScanManager() { String confluentSchemaRegistryId = "confluentId"; ScanRequestBO scanRequestBO = new ScanRequestBO( - messagingServiceId, "scanId", "traceId", + messagingServiceId, "scanId", "traceId", "actorId", List.of("KAFKA_ALL", "CONFLUENT_SCHEMA_REGISTRY_SCHEMA"), List.of("FILE_WRITER")); @@ -147,7 +150,7 @@ void testScanManager() { .thenReturn(destinations); when(kafkaRouteDelegate.generateRouteList(destinations, List.of(), "KAFKA_ALL", messagingServiceId)) .thenReturn(routes); - when(scanService.singleScan(List.of(), "groupId", "scanId", "traceId", + when(scanService.singleScan(List.of(), "groupId", "scanId", "traceId", "actorId", mock(MessagingServiceEntity.class), "runtimeAgent1")) .thenReturn(Mockito.anyString()); diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/mapper/ScanRequestMapperTest.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/mapper/ScanRequestMapperTest.java index 6e38962d..05d1bb4f 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/mapper/ScanRequestMapperTest.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/mapper/ScanRequestMapperTest.java @@ -1,9 +1,9 @@ package com.solace.maas.ep.event.management.agent.scanManager.mapper; +import com.solace.maas.ep.common.model.ScanRequestDTO; import com.solace.maas.ep.event.management.agent.TestConfig; import com.solace.maas.ep.event.management.agent.model.User; import com.solace.maas.ep.event.management.agent.scanManager.model.ScanRequestBO; -import com.solace.maas.ep.common.model.ScanRequestDTO; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -31,6 +31,7 @@ public void testMapper() { "id", "scanId", "traceId", + "actorId", List.of("TEST_SCAN"), List.of()); @@ -47,6 +48,7 @@ public void testMapperWithUser() { "id", "scanId", "traceId", + "actorId", List.of("TEST_SCAN"), List.of()); diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerTests.java index 93466da1..3c7b9fdc 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerTests.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/DataImportControllerTests.java @@ -4,11 +4,13 @@ import com.solace.maas.ep.event.management.agent.scanManager.model.ImportRequestBO; import com.solace.maas.ep.event.management.agent.scanManager.model.ZipRequestBO; import com.solace.maas.ep.event.management.agent.service.ImportService; +import io.micrometer.tracing.Tracer; import lombok.SneakyThrows; import org.junit.Rule; import org.junit.jupiter.api.Test; import org.junit.rules.ExpectedException; import org.mockito.Mock; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.core.io.InputStreamResource; import org.springframework.http.HttpStatus; @@ -37,11 +39,14 @@ public class DataImportControllerTests { @Mock ImportService importService; + @Autowired + Tracer tracer; + @SneakyThrows @Test public void testDataImportControllerRead() { - DataImportController controller = new DataImportControllerImpl(importService); + DataImportController controller = new DataImportControllerImpl(importService, tracer); MultipartFile multipartFile = new MockMultipartFile("file", "test.json", MediaType.APPLICATION_JSON_VALUE, @@ -59,7 +64,7 @@ public void testDataImportControllerRead() { @Test public void testDataImportControllerZip() { - DataImportController controller = new DataImportControllerImpl(importService); + DataImportController controller = new DataImportControllerImpl(importService, tracer); ZipRequestBO zipRequestBO = ZipRequestBO.builder() .scanId("scanId") @@ -80,7 +85,7 @@ public void testDataImportControllerZip() { @Test public void testDataImportControllerZipWithBadRequest() { - DataImportController controller = new DataImportControllerImpl(importService); + DataImportController controller = new DataImportControllerImpl(importService, tracer); ResponseEntity reply = controller.zip("scanId"); @@ -93,7 +98,7 @@ public void testDataImportControllerZipWithBadRequest() { @SneakyThrows @Test public void testDataImportControllerException() { - DataImportController controller = new DataImportControllerImpl(importService); + DataImportController controller = new DataImportControllerImpl(importService, tracer); MultipartFile multipartFile = new MockMultipartFile("file", "test.json", MediaType.APPLICATION_JSON_VALUE, diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/EMAControllerTest.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/EMAControllerTest.java index e250d258..a6689282 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/EMAControllerTest.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/scanManager/rest/EMAControllerTest.java @@ -45,6 +45,7 @@ public void testEMAControllerInConnectedMode() { "id", "scanConnected", "traceId", + "actorId", List.of("TEST_SCAN_TYPE"), List.of()); @@ -75,6 +76,7 @@ public void testEMAControllerInStandAloneModeWithEventPortalDestination() { "id", "scanId", "traceId", + "actorId", List.of("TEST_SCAN"), List.of("EVENT_PORTAL")); @@ -104,6 +106,7 @@ public void testEMAControllerInStandAloneMode() { "id", "scanId", "traceId", + "actorId", List.of("TEST_SCAN"), List.of()); diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java index d2844f56..df792469 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java @@ -42,13 +42,13 @@ import java.util.UUID; import java.util.concurrent.CompletableFuture; -import static org.assertj.core.api.Assertions.assertThatNoException; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatNoException; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; -import static org.mockito.Mockito.when; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; @ActiveProfiles("TEST") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = TestConfig.class) @@ -151,6 +151,7 @@ public void testSingleScanWithRouteBundle() { "groupId", "scanId", "traceId", + "actorId", mock(MessagingServiceEntity.class), "runtimeAgent1"); @@ -312,7 +313,7 @@ public void testSendScanStatus() { ScanService service = new ScanService(mock(ScanRepository.class), mock(ScanRecipientHierarchyRepository.class), mock(ScanTypeRepository.class), mock(ScanStatusRepository.class), mock(ScanRouteService.class), mock(RouteService.class), template, idGenerator); - service.sendScanStatus("scanId", "groupId", "messagingServiceId", "traceId", + service.sendScanStatus("scanId", "groupId", "messagingServiceId", "traceId", "actorId", "queueListing", ScanStatus.IN_PROGRESS); assertThatNoException(); diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/constants/RouteConstants.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/constants/RouteConstants.java index 6329f2b5..f4763a91 100644 --- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/constants/RouteConstants.java +++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/constants/RouteConstants.java @@ -9,7 +9,9 @@ public class RouteConstants { public static final String SCAN_ID = "SCAN_ID"; - public static final String TRACE_ID = "TRACE_ID"; + public static final String TRACE_ID = "traceId"; + + public static final String ACTOR_ID = "ACTOR_ID"; public static final String SCAN_TYPE = "SCAN_TYPE"; diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/mop/MOPMessage.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/mop/MOPMessage.java index fe5a3bd7..739f52a4 100644 --- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/mop/MOPMessage.java +++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/mop/MOPMessage.java @@ -74,6 +74,9 @@ public enum DestinationType { private String destinationName; private DestinationType destinationType; + private String actorId; + private String orgId; + // This field indicates the priority of the message. // Default is 4. Valid number is from 0(lowest) to 9(highest) // This field can only take effect when the destination queue or topic endpoint has toggled `Respect Message diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/processor/logging/MDCProcessor.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/processor/logging/MDCProcessor.java index 15feb9bf..e30269ee 100644 --- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/processor/logging/MDCProcessor.java +++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/processor/logging/MDCProcessor.java @@ -19,6 +19,9 @@ public void process(Exchange exchange) throws Exception { MDC.put(RouteConstants.TRACE_ID, exchange.getIn().getHeader(RouteConstants.TRACE_ID, String.class)); + MDC.put(RouteConstants.ACTOR_ID, + exchange.getIn().getHeader(RouteConstants.ACTOR_ID, String.class)); + MDC.put(RouteConstants.SCAN_TYPE, exchange.getIn().getHeader(RouteConstants.SCAN_TYPE, String.class)); diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/ScanStatusMarkerAndLoggerRouteBuilder.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/ScanStatusMarkerAndLoggerRouteBuilder.java index fde7b609..820c62c4 100644 --- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/ScanStatusMarkerAndLoggerRouteBuilder.java +++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/base/ScanStatusMarkerAndLoggerRouteBuilder.java @@ -15,11 +15,13 @@ public void configure() throws Exception { from("direct:markRouteScanStatusInProgress") .routeId("markRouteScanStatusInProgress") .log("Scan request [${header." + RouteConstants.SCAN_ID + "}], trace ID [${header." + - RouteConstants.TRACE_ID + "}]: The status of [${header." + + RouteConstants.TRACE_ID + "}]: actorId [${header." + RouteConstants.ACTOR_ID + "}]:" + + " The status of [${header." + RouteConstants.SCAN_TYPE + "}]" + " is: [" + ScanStatus.IN_PROGRESS + "].") .to("direct:perRouteScanStatusPublisher?block=false&failIfNoConsumers=false") .log("Scan request [${header." + RouteConstants.SCAN_ID + "}], trace ID [${header." + - RouteConstants.TRACE_ID + "}]: Retrieving [${header." + RouteConstants.SCAN_TYPE + RouteConstants.TRACE_ID + "}]: actorId [${header." + RouteConstants.ACTOR_ID + "}]:" + + " Retrieving [${header." + RouteConstants.SCAN_TYPE + "}] details from event broker [${header." + RouteConstants.MESSAGING_SERVICE_ID + "}]."); @@ -27,18 +29,21 @@ public void configure() throws Exception { .routeId("markRouteScanStatusComplete") .to("direct:processScanStatusAsComplete?block=false&failIfNoConsumers=false") .log("Scan request [${header." + RouteConstants.SCAN_ID + "}], trace ID [${header." + - RouteConstants.TRACE_ID + "}]: The status of [${header." + + RouteConstants.TRACE_ID + "}]: actorId [${header." + RouteConstants.ACTOR_ID + "}]:" + + "The status of [${header." + RouteConstants.SCAN_TYPE + "}]" + " is: [" + ScanStatus.COMPLETE + "]."); from("direct:markRouteImportStatusInProgress") .routeId("markRouteImportStatusInProgress") .log("Scan import request [${header." + RouteConstants.SCAN_ID + "}], trace ID [${header." + - RouteConstants.TRACE_ID + "}]: The status of [${header." + + RouteConstants.TRACE_ID + "}]: actorId [${header." + RouteConstants.ACTOR_ID + "}]:" + + "The status of [${header." + RouteConstants.SCAN_TYPE + "}]" + " is: [" + ScanStatus.IN_PROGRESS + "].") .to("direct:perRouteScanStatusPublisher?block=false&failIfNoConsumers=false") .log("Scan import request [${header." + RouteConstants.SCAN_ID + "}], trace ID [${header." + - RouteConstants.TRACE_ID + "}]: Retrieving [${header." + + RouteConstants.TRACE_ID + "}]: actorId [${header." + RouteConstants.ACTOR_ID + "}]:" + + "The status of [${header." + RouteConstants.SCAN_TYPE + "}] details from file: [${body.fileName}]."); @@ -46,7 +51,8 @@ public void configure() throws Exception { .routeId("markRouteImportStatusComplete") .to("direct:processScanStatusAsComplete?block=false&failIfNoConsumers=false") .log("Scan import request [${header." + RouteConstants.SCAN_ID + "}], trace ID [${header." + - RouteConstants.TRACE_ID + "}]: The status of [${header." + + RouteConstants.TRACE_ID + "}]: actorId [${header." + RouteConstants.ACTOR_ID + "}]:" + + "The status of [${header." + RouteConstants.SCAN_TYPE + "}]" + " is: [" + ScanStatus.COMPLETE + "]."); } } From 493bb9c7a5bde92b5c5987d62147b47c239105b2 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Wed, 18 Oct 2023 16:18:50 +0000 Subject: [PATCH 3/4] [ci skip] prepare release v1.2.0 --- service/application/pom.xml | 17 ++++++++--------- .../confluent-schema-registry-plugin/pom.xml | 4 ++-- service/kafka-plugin/pom.xml | 4 ++-- service/local-storage-plugin/pom.xml | 4 ++-- service/plugin/pom.xml | 4 ++-- service/pom.xml | 4 ++-- service/rabbitmq-plugin/pom.xml | 4 ++-- service/solace-plugin/pom.xml | 4 ++-- 8 files changed, 22 insertions(+), 23 deletions(-) diff --git a/service/application/pom.xml b/service/application/pom.xml index a716b539..c413db62 100644 --- a/service/application/pom.xml +++ b/service/application/pom.xml @@ -1,16 +1,15 @@ - + 4.0.0 com.solace.maas maas-event-management-agent-parent - 1.1.2-SNAPSHOT + 1.2.0 .. com.solace.maas event-management-agent - 1.1.2-SNAPSHOT + 1.2.0 jar Solace Event Management Agent - Application Solace Event Management Agent - Application @@ -254,27 +253,27 @@ com.solace.maas plugin - 1.1.2-SNAPSHOT + 1.2.0 com.solace.maas.plugin.kafka kafka-plugin - 1.1.2-SNAPSHOT + 1.2.0 com.solace.maas.plugin.solace solace-plugin - 1.1.2-SNAPSHOT + 1.2.0 com.solace.maas.plugin.localstorage local-storage-plugin - 1.1.2-SNAPSHOT + 1.2.0 com.solace.maas.plugin.confluent-schema-registry confluent-schema-registry-plugin - 1.1.2-SNAPSHOT + 1.2.0 diff --git a/service/confluent-schema-registry-plugin/pom.xml b/service/confluent-schema-registry-plugin/pom.xml index 2b5e3749..930e3083 100644 --- a/service/confluent-schema-registry-plugin/pom.xml +++ b/service/confluent-schema-registry-plugin/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.solace.maas.plugin.confluent-schema-registry confluent-schema-registry-plugin - 1.1.2-SNAPSHOT + 1.2.0 jar Solace Event Management Agent - Confluent Schema Registry Plugin Solace Event Management Agent - Confluent Schema Registry Plugin @@ -22,7 +22,7 @@ com.solace.maas plugin - 1.1.2-SNAPSHOT + 1.2.0 org.springframework.boot diff --git a/service/kafka-plugin/pom.xml b/service/kafka-plugin/pom.xml index e321d7cd..a8180a60 100644 --- a/service/kafka-plugin/pom.xml +++ b/service/kafka-plugin/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.solace.maas.plugin.kafka kafka-plugin - 1.1.2-SNAPSHOT + 1.2.0 jar Solace Event Management Agent - Kafka Plugin Solace Event Management Agent - Kafka Plugin @@ -63,7 +63,7 @@ com.solace.maas plugin - 1.1.2-SNAPSHOT + 1.2.0 org.junit.jupiter diff --git a/service/local-storage-plugin/pom.xml b/service/local-storage-plugin/pom.xml index 45f75f89..d517ac1d 100644 --- a/service/local-storage-plugin/pom.xml +++ b/service/local-storage-plugin/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.solace.maas.plugin.localstorage local-storage-plugin - 1.1.2-SNAPSHOT + 1.2.0 jar Solace Event Management Agent - Local Storage Plugin Solace Event Management Agent - Local Storage Plugin @@ -106,7 +106,7 @@ com.solace.maas plugin - 1.1.2-SNAPSHOT + 1.2.0 org.json diff --git a/service/plugin/pom.xml b/service/plugin/pom.xml index 5160799c..9fe22ef2 100644 --- a/service/plugin/pom.xml +++ b/service/plugin/pom.xml @@ -4,12 +4,12 @@ com.solace.maas maas-event-management-agent-parent - 1.1.2-SNAPSHOT + 1.2.0 .. com.solace.maas plugin - 1.1.2-SNAPSHOT + 1.2.0 jar Solace Event Management Agent - Plugin Solace Event Management Agent - Plugin diff --git a/service/pom.xml b/service/pom.xml index bf3769bc..72a5646b 100644 --- a/service/pom.xml +++ b/service/pom.xml @@ -9,7 +9,7 @@ com.solace.maas maas-event-management-agent-parent - 1.1.2-SNAPSHOT + 1.2.0 pom Solace Event Management Agent Maven Parent Solace Solace Event Management Agent Maven Parent @@ -402,7 +402,7 @@ scm:git:${project.scm.url} scm:git:${project.scm.url} git@github.com:SolaceProducts/event-management-agent.git - HEAD + v1.2.0 diff --git a/service/rabbitmq-plugin/pom.xml b/service/rabbitmq-plugin/pom.xml index ef3d30c8..874929f7 100644 --- a/service/rabbitmq-plugin/pom.xml +++ b/service/rabbitmq-plugin/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.solace.maas.plugin.rabbitmq rabbitmq-plugin - 1.1.2-SNAPSHOT + 1.2.0 jar Solace Event Management Agent - RabbitMQ Plugin Solace Event Management Agent - RabbitMQ Plugin @@ -25,7 +25,7 @@ com.solace.maas plugin - 1.1.2-SNAPSHOT + 1.2.0 diff --git a/service/solace-plugin/pom.xml b/service/solace-plugin/pom.xml index e252c6a8..7cbf5029 100644 --- a/service/solace-plugin/pom.xml +++ b/service/solace-plugin/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.solace.maas.plugin.solace solace-plugin - 1.1.2-SNAPSHOT + 1.2.0 jar Solace Event Management Agent - Solace Plugin Solace Event Management Agent - Solace Plugin @@ -88,7 +88,7 @@ com.solace.maas plugin - 1.1.2-SNAPSHOT + 1.2.0 org.yaml From 352339ec27dc8ac2a5097a73f538771c8b5aff21 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Wed, 18 Oct 2023 16:18:53 +0000 Subject: [PATCH 4/4] [ci skip] prepare for next development iteration --- service/application/pom.xml | 14 +++++++------- service/confluent-schema-registry-plugin/pom.xml | 4 ++-- service/kafka-plugin/pom.xml | 4 ++-- service/local-storage-plugin/pom.xml | 4 ++-- service/plugin/pom.xml | 4 ++-- service/pom.xml | 4 ++-- service/rabbitmq-plugin/pom.xml | 4 ++-- service/solace-plugin/pom.xml | 4 ++-- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/service/application/pom.xml b/service/application/pom.xml index c413db62..b4da5a45 100644 --- a/service/application/pom.xml +++ b/service/application/pom.xml @@ -4,12 +4,12 @@ com.solace.maas maas-event-management-agent-parent - 1.2.0 + 1.2.0-SNAPSHOT .. com.solace.maas event-management-agent - 1.2.0 + 1.2.0-SNAPSHOT jar Solace Event Management Agent - Application Solace Event Management Agent - Application @@ -253,27 +253,27 @@ com.solace.maas plugin - 1.2.0 + 1.2.0-SNAPSHOT com.solace.maas.plugin.kafka kafka-plugin - 1.2.0 + 1.2.0-SNAPSHOT com.solace.maas.plugin.solace solace-plugin - 1.2.0 + 1.2.0-SNAPSHOT com.solace.maas.plugin.localstorage local-storage-plugin - 1.2.0 + 1.2.0-SNAPSHOT com.solace.maas.plugin.confluent-schema-registry confluent-schema-registry-plugin - 1.2.0 + 1.2.0-SNAPSHOT diff --git a/service/confluent-schema-registry-plugin/pom.xml b/service/confluent-schema-registry-plugin/pom.xml index 930e3083..da77fa16 100644 --- a/service/confluent-schema-registry-plugin/pom.xml +++ b/service/confluent-schema-registry-plugin/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.solace.maas.plugin.confluent-schema-registry confluent-schema-registry-plugin - 1.2.0 + 1.2.0-SNAPSHOT jar Solace Event Management Agent - Confluent Schema Registry Plugin Solace Event Management Agent - Confluent Schema Registry Plugin @@ -22,7 +22,7 @@ com.solace.maas plugin - 1.2.0 + 1.2.0-SNAPSHOT org.springframework.boot diff --git a/service/kafka-plugin/pom.xml b/service/kafka-plugin/pom.xml index a8180a60..ff9f222c 100644 --- a/service/kafka-plugin/pom.xml +++ b/service/kafka-plugin/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.solace.maas.plugin.kafka kafka-plugin - 1.2.0 + 1.2.0-SNAPSHOT jar Solace Event Management Agent - Kafka Plugin Solace Event Management Agent - Kafka Plugin @@ -63,7 +63,7 @@ com.solace.maas plugin - 1.2.0 + 1.2.0-SNAPSHOT org.junit.jupiter diff --git a/service/local-storage-plugin/pom.xml b/service/local-storage-plugin/pom.xml index d517ac1d..8f151045 100644 --- a/service/local-storage-plugin/pom.xml +++ b/service/local-storage-plugin/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.solace.maas.plugin.localstorage local-storage-plugin - 1.2.0 + 1.2.0-SNAPSHOT jar Solace Event Management Agent - Local Storage Plugin Solace Event Management Agent - Local Storage Plugin @@ -106,7 +106,7 @@ com.solace.maas plugin - 1.2.0 + 1.2.0-SNAPSHOT org.json diff --git a/service/plugin/pom.xml b/service/plugin/pom.xml index 9fe22ef2..aef260be 100644 --- a/service/plugin/pom.xml +++ b/service/plugin/pom.xml @@ -4,12 +4,12 @@ com.solace.maas maas-event-management-agent-parent - 1.2.0 + 1.2.0-SNAPSHOT .. com.solace.maas plugin - 1.2.0 + 1.2.0-SNAPSHOT jar Solace Event Management Agent - Plugin Solace Event Management Agent - Plugin diff --git a/service/pom.xml b/service/pom.xml index 72a5646b..8ffb82bb 100644 --- a/service/pom.xml +++ b/service/pom.xml @@ -9,7 +9,7 @@ com.solace.maas maas-event-management-agent-parent - 1.2.0 + 1.2.0-SNAPSHOT pom Solace Event Management Agent Maven Parent Solace Solace Event Management Agent Maven Parent @@ -402,7 +402,7 @@ scm:git:${project.scm.url} scm:git:${project.scm.url} git@github.com:SolaceProducts/event-management-agent.git - v1.2.0 + HEAD diff --git a/service/rabbitmq-plugin/pom.xml b/service/rabbitmq-plugin/pom.xml index 874929f7..e82ae557 100644 --- a/service/rabbitmq-plugin/pom.xml +++ b/service/rabbitmq-plugin/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.solace.maas.plugin.rabbitmq rabbitmq-plugin - 1.2.0 + 1.2.0-SNAPSHOT jar Solace Event Management Agent - RabbitMQ Plugin Solace Event Management Agent - RabbitMQ Plugin @@ -25,7 +25,7 @@ com.solace.maas plugin - 1.2.0 + 1.2.0-SNAPSHOT diff --git a/service/solace-plugin/pom.xml b/service/solace-plugin/pom.xml index 7cbf5029..3e5d7050 100644 --- a/service/solace-plugin/pom.xml +++ b/service/solace-plugin/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.solace.maas.plugin.solace solace-plugin - 1.2.0 + 1.2.0-SNAPSHOT jar Solace Event Management Agent - Solace Plugin Solace Event Management Agent - Solace Plugin @@ -88,7 +88,7 @@ com.solace.maas plugin - 1.2.0 + 1.2.0-SNAPSHOT org.yaml