Skip to content

Commit

Permalink
add EMA version to heartbeat message
Browse files Browse the repository at this point in the history
  • Loading branch information
Puck Wang committed Oct 6, 2023
1 parent c33d169 commit 9d01f34
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
14 changes: 13 additions & 1 deletion service/application/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.solace.maas</groupId>
Expand Down Expand Up @@ -341,6 +342,17 @@
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class HeartbeatMessage extends MOPMessage {
private String orgId;
private String runtimeAgentId;
private String timestamp;
private String runtimeAgentVersion;

public HeartbeatMessage() {
super();
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}

Expand Down

0 comments on commit 9d01f34

Please sign in to comment.