Skip to content

Commit

Permalink
Merge pull request #9 from hivemq/update-4.22.0
Browse files Browse the repository at this point in the history
Update 4.22.0
  • Loading branch information
skobow committed Dec 5, 2023
2 parents f264e7c + 9433c7e commit 54f4c8c
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 18 deletions.
2 changes: 0 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ image:https://img.shields.io/github/v/release/hivemq/hivemq-sparkplug-aware-exte
image:https://img.shields.io/github/license/hivemq/hivemq-sparkplug-aware-extension?style=for-the-badge&color=brightgreen[GitHub,link=LICENSE]
image:https://img.shields.io/github/actions/workflow/status/hivemq/hivemq-sparkplug-aware-extension/check.yml?branch=master&style=for-the-badge[GitHub Workflow Status,link=https://github.com/hivemq/hivemq-sparkplug-aware-extension/actions/workflows/check.yml?query=branch%3Amaster]

*This extension is not yet ready for production use.*

== Purpose

This HiveMQ Sparkplug aware extension has the purpose to fulfil the new link:https://github.com/eclipse/sparkplug[Sparkplug Release] of the Sparkplug specification extend HiveMQ with the functionality of a Sparkplug Aware Broker wich is an optional Requirement.
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
commonsLang = "3.8.1"
guava = "31.1-jre"
hivemq-extensionSdk = "4.9.1"
hivemq-extensionSdk = "4.22.0"
jackson = "2.13.2"
jacksonv1 = "1.9.13"
jetbrains-annotations = "24.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
*/
package com.hivemq.extensions.sparkplug.aware;

public class AwareRequirements {
public final static String CONFORMANCE_MQTT_AWARE_NBIRTH_MQTT_TOPIC = "A Sparkplug Aware MQTT Server MUST make NBIRTH messages available on a topic of the form: $sparkplug/certificates/namespace/group_id/NBIRTH/edge_node_id";
public final static String CONFORMANCE_MQTT_AWARE_NBIRTH_MQTT_RETAIN = "A Sparkplug Aware MQTT Server MUST make NBIRTH messages available on the topic: $sparkplug/certificates/namespace/group_id/NBIRTH/edge_node_id with the MQTT retain flag set to true";
public final static String CONFORMANCE_MQTT_AWARE_DBIRTH_MQTT_TOPIC = "A Sparkplug Aware MQTT Server MUST make DBIRTH messages available on a topic of the form: $sparkplug/certificates/namespace/group_id/DBIRTH/edge_node_id/device_id";
public final static String CONFORMANCE_MQTT_AWARE_DBIRTH_MQTT_RETAIN = "A Sparkplug Aware MQTT Server MUST make DBIRTH messages available on the topic: $sparkplug/certificates/namespace/group_id/DBIRTH/edge_node_id/device_id with the MQTT retain flag set to true";
public final static String CONFORMANCE_MQTT_AWARE_NDEATH_TIMESTAMP = "A Sparkplug Aware MQTT Server MAY replace the timestamp of NDEATH messages. If it does, it MUST set the timestamp to the UTC time at which it attempts to deliver the NDEATH to subscribed clients";
public final class AwareRequirements {

AwareRequirements() {
}

public static final String CONFORMANCE_MQTT_AWARE_NBIRTH_MQTT_TOPIC = "A Sparkplug Aware MQTT Server MUST make NBIRTH messages available on a topic of the form: $sparkplug/certificates/namespace/group_id/NBIRTH/edge_node_id";
public static final String CONFORMANCE_MQTT_AWARE_NBIRTH_MQTT_RETAIN = "A Sparkplug Aware MQTT Server MUST make NBIRTH messages available on the topic: $sparkplug/certificates/namespace/group_id/NBIRTH/edge_node_id with the MQTT retain flag set to true";
public static final String CONFORMANCE_MQTT_AWARE_DBIRTH_MQTT_TOPIC = "A Sparkplug Aware MQTT Server MUST make DBIRTH messages available on a topic of the form: $sparkplug/certificates/namespace/group_id/DBIRTH/edge_node_id/device_id";
public static final String CONFORMANCE_MQTT_AWARE_DBIRTH_MQTT_RETAIN = "A Sparkplug Aware MQTT Server MUST make DBIRTH messages available on the topic: $sparkplug/certificates/namespace/group_id/DBIRTH/edge_node_id/device_id with the MQTT retain flag set to true";
public static final String CONFORMANCE_MQTT_AWARE_NDEATH_TIMESTAMP = "A Sparkplug Aware MQTT Server MAY replace the timestamp of NDEATH messages. If it does, it MUST set the timestamp to the UTC time at which it attempts to deliver the NDEATH to subscribed clients";
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void extensionStart(
addPublishModifier();

final ExtensionInformation extensionInformation = extensionStartInput.getExtensionInformation();
log.info("Started " + extensionInformation.getName() + ":" + extensionInformation.getVersion());
log.info("Started {}:{}", extensionInformation.getName(), extensionInformation.getVersion());

log.debug("Add Awareness: {} ", AwareRequirements.CONFORMANCE_MQTT_AWARE_DBIRTH_MQTT_TOPIC);
log.debug("Add Awareness: {} ", AwareRequirements.CONFORMANCE_MQTT_AWARE_DBIRTH_MQTT_RETAIN);
Expand All @@ -75,7 +75,7 @@ public void extensionStop(
final @NotNull ExtensionStopOutput extensionStopOutput) {

final ExtensionInformation extensionInformation = extensionStopInput.getExtensionInformation();
log.info("Stopped " + extensionInformation.getName() + ":" + extensionInformation.getVersion());
log.info("Stopped {}:{}", extensionInformation.getName(), extensionInformation.getVersion());
}

private void addPublishModifier() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public class SparkplugPublishInboundInterceptor implements PublishInboundInterce
private final PublishService publishService;
private final @NotNull String sparkplugVersion;
private final @NotNull String sysTopic;
private final Boolean useCompression;
private final Boolean jsonLogEnabled;
private final boolean useCompression;
private final boolean jsonLogEnabled;
private final Long messageExpiry;

public SparkplugPublishInboundInterceptor(final @NotNull SparkplugConfiguration configuration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public class SparkplugPublishOutboundInterceptor implements PublishOutboundInter
private static final CompressionAlgorithm compressionAlgorithm = CompressionAlgorithm.GZIP;
private final @NotNull String sparkplugVersion;

private final Boolean useCompression;
private final Boolean jsonLogEnabled;
private final boolean useCompression;
private final boolean jsonLogEnabled;

public SparkplugPublishOutboundInterceptor(final @NotNull SparkplugConfiguration configuration) {
this.sparkplugVersion = configuration.getSparkplugVersion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,20 @@
import java.nio.ByteBuffer;
import java.util.Date;

public class PayloadUtil {
public final class PayloadUtil {
private static final @NotNull Logger log = LoggerFactory.getLogger(PayloadUtil.class);
private static final @NotNull Logger jsonLog = LoggerFactory.getLogger("com.hivemq.extensions.sparkplug.jsonLog");
private static final CompressionAlgorithm compressionAlgorithm = CompressionAlgorithm.GZIP;

public static ByteBuffer modifySparkplugTimestamp(Boolean useCompression, ByteBuffer byteBuffer) throws Exception {
SparkplugBPayload inboundPayload = getSparkplugBPayload(byteBuffer);
PayloadUtil(){
}

public static ByteBuffer modifySparkplugTimestamp(boolean useCompression, ByteBuffer byteBuffer) throws Exception {
final SparkplugBPayload inboundPayload = getSparkplugBPayload(byteBuffer);
if (inboundPayload == null) {
throw new IllegalArgumentException("Unable to get Sparkplug B Payload from byte buffer.");
}

//create the same payload with a new timestamp.
SparkplugBPayload payload =
new SparkplugBPayload(new Date(),
Expand Down

0 comments on commit 54f4c8c

Please sign in to comment.