From 9d01f340ad6dc0803cf9dd8e13a955bac1d59a96 Mon Sep 17 00:00:00 2001 From: Puck Wang Date: Tue, 3 Oct 2023 10:51:31 -0400 Subject: [PATCH] add EMA version to heartbeat message --- service/application/pom.xml | 14 +++++++++++++- .../maas/ep/common/messages/HeartbeatMessage.java | 12 ++++++++++++ .../agent/publisher/HeartbeatGenerator.java | 9 ++++++--- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/service/application/pom.xml b/service/application/pom.xml index b9fabafb..3e04a3f9 100644 --- a/service/application/pom.xml +++ b/service/application/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 com.solace.maas @@ -341,6 +342,17 @@ + + org.springframework.boot + spring-boot-maven-plugin + + + + build-info + + + + diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/HeartbeatMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/HeartbeatMessage.java index 1e1a17a1..c2998667 100644 --- a/service/application/src/main/java/com/solace/maas/ep/common/messages/HeartbeatMessage.java +++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/HeartbeatMessage.java @@ -12,6 +12,7 @@ public class HeartbeatMessage extends MOPMessage { private String orgId; private String runtimeAgentId; private String timestamp; + private String runtimeAgentVersion; public HeartbeatMessage() { super(); @@ -27,6 +28,17 @@ public HeartbeatMessage(String runtimeAgentId, String timestamp) { this.timestamp = timestamp; } + public HeartbeatMessage(String runtimeAgentId, String timestamp, String runtimeAgentVersion) { + super(); + withMessageType(MOPMessageType.generic) + .withProtocol(MOPProtocol.EMAHeartbeat) + .withVersion("1") + .withUhFlag(MOPUHFlag.ignore); + this.runtimeAgentId = runtimeAgentId; + this.timestamp = timestamp; + this.runtimeAgentVersion = runtimeAgentVersion; + } + @Override public String toLog() { return null; diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/HeartbeatGenerator.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/HeartbeatGenerator.java index 3f4026b8..d62f4b9f 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/HeartbeatGenerator.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/HeartbeatGenerator.java @@ -6,6 +6,7 @@ import com.solace.maas.ep.event.management.agent.plugin.jacoco.ExcludeFromJacocoGeneratedReport; import com.solace.maas.ep.event.management.agent.plugin.publisher.SolacePublisher; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.boot.info.BuildProperties; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -19,19 +20,21 @@ public class HeartbeatGenerator { private final SolacePublisher solacePublisher; private final String runtimeAgentId; private final String topic; + private final String runtimeAgentVersion; public HeartbeatGenerator(SolaceConfiguration solaceConfiguration, EventPortalProperties eventPortalProperties, - SolacePublisher solacePublisher) { + SolacePublisher solacePublisher, + BuildProperties buildProperties) { this.solacePublisher = solacePublisher; this.runtimeAgentId = eventPortalProperties.getRuntimeAgentId(); topic = solaceConfiguration.getTopicPrefix() + "heartbeat/v1"; - + this.runtimeAgentVersion = buildProperties.getVersion().substring(0, buildProperties.getVersion().indexOf('-')); } @Scheduled(fixedRate = 5000) public void sendHeartbeat() { - HeartbeatMessage message = new HeartbeatMessage(runtimeAgentId, Instant.now().toString()); + HeartbeatMessage message = new HeartbeatMessage(runtimeAgentId, Instant.now().toString(), runtimeAgentVersion); solacePublisher.publish(message, topic); }