Skip to content

Commit

Permalink
Finalize migration with all tests green
Browse files Browse the repository at this point in the history
  • Loading branch information
skobow committed Jun 27, 2023
1 parent 82e7edc commit 5630c25
Show file tree
Hide file tree
Showing 40 changed files with 1,303 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* for message delivery.
*
* @author Sven Kobow
* @since 3.0.0
*/
public class MqttMessage {

Expand All @@ -44,113 +45,129 @@ public MqttMessage(final byte[] payload) {

/**
* Returns whether the message is mutable.
* @return mutable
* @return mutable.
*/
public boolean getMutable() {
return mutable;
}

/**
* Sets whether the message is mutable.
* @param mutable boolean value
* @param mutable boolean value.
*/
public void setMutable(final boolean mutable) {
this.mutable = mutable;
}

/**
* Returns the payload as byte array.
* @return payload The payload byte array
* @return payload The payload byte array.
*/
public byte[] getPayload() {
return payload;
}

/**
* Sets the payload of the message.
* @param payload The payload as byte array
* @param payload The payload as byte array.
*/
public void setPayload(final byte[] payload) {
this.payload = payload;
}

/**
* Returns the quality of service level for the message.
* @return MQTT quality of service level
* @return MQTT quality of service level.
*/
public int getQos() {
return qos;
}

/**
* Sets the quality of service level for the message.
* @param qos MQTT quality of service level
* @param qos MQTT quality of service level.
*/
public void setQos(final int qos) {
this.qos = qos;
}

/**
* Returns whether the message is a retained message.
* @return boolean value
* @return boolean value.
*/
public boolean isRetained() {
return retained;
}

/**
* Sets whether the message is retained.
* @param retained boolean value
* @param retained boolean value.
*/
public void setRetained(final boolean retained) {
this.retained = retained;
}

/**
* Returns whether the message is flagged as duplicate.
* @return boolean value
* @return boolean value.
*/
public boolean getDup() {
return dup;
}

/**
* Flags the message as duplicate.
* @param dup boolean value
* @param dup boolean value.
*/
public void setDup(final boolean dup) {
this.dup = dup;
}

/**
* Returns the message id.
* @return message id
* @return message id.
*/
public int getId() {
return messageId;
}

/**
* Sets the message id.
* @param messageId message id
* @param messageId message id.
*/
public void setId(final int messageId) {
this.messageId = messageId;
}

/**
* Sets the MQTT user properties.
* @param userProperties MQTT user properties
* @param userProperties MQTT user properties.
*/
public void setUserProperties(final List<UserProperty> userProperties) {
this.userProperties = userProperties;
}

/**
* Returns the MQTT user properties.
* @return MQTT user properties
* @return MQTT user properties.
*/
public List<UserProperty> getUserProperties() {
return this.userProperties;
}

/**
* Returns the correlation data for the message.
* @return the correlation data.
*/
public byte[] getCorrelationData() {
return correlationData;
}

/**
* Sets the correlation data for the message.
* @param correlationData the correlation data.
*/
public void setCorrelationData(byte[] correlationData) {
this.correlationData = correlationData;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,27 @@
import io.micronaut.mqtt.bind.MqttBindingContext;
import io.micronaut.mqtt.hivemq.bind.MqttMessage;

import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
* Common interface for HiveMQ MQTT clients.
*
* @author Sven Kobow
* @since 3.0.0
*/
public interface MqttClientAdapter {

void subscribe(String[] topics, int[] qos, Consumer<MqttBindingContext<MqttMessage>> callback);

default Map<String, Integer> getTopicMap(String[] topics, int[] qos) {
return IntStream.range(0, topics.length).boxed()
.collect(Collectors.toMap(i -> topics[i], i -> qos[i]));
}

void unsubscribe(Set<String> topics);

boolean isConnected();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
import java.security.cert.Certificate;
import java.security.cert.CertificateException;

/**
* Common interface for MQTT client factories.
*
* @author Sven Kobow
* @since 3.0.3
* @see io.micronaut.mqtt.hivemq.v3.client.Mqtt3ClientFactory
* @see io.micronaut.mqtt.hivemq.v5.client.Mqtt5ClientFactory
*/
public interface MqttClientFactory {

default KeyManagerFactory getKeyManagerFactory(final MqttCertificateConfiguration certConfiguration) throws KeyManagerFactoryCreationException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@

import java.util.Collections;

/**
* A {@link HealthIndicator} for HiveMQ MQTT Client.
*
* @author Sven Kobow
* @since 3.0.0
*/
@Requires(property = HealthEndpoint.PREFIX + ".mqtt.client.enabled", value = StringUtils.TRUE)
@Requires(beans = HealthEndpoint.class)
@Singleton
Expand Down
Loading

0 comments on commit 5630c25

Please sign in to comment.