Skip to content

Commit 5630c25

Browse files
committed
Finalize migration with all tests green
1 parent 82e7edc commit 5630c25

File tree

40 files changed

+1303
-65
lines changed

40 files changed

+1303
-65
lines changed

mqtt-hivemq/src/main/java/io/micronaut/mqtt/hivemq/bind/MqttMessage.java

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* for message delivery.
2323
*
2424
* @author Sven Kobow
25+
* @since 3.0.0
2526
*/
2627
public class MqttMessage {
2728

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

4546
/**
4647
* Returns whether the message is mutable.
47-
* @return mutable
48+
* @return mutable.
4849
*/
4950
public boolean getMutable() {
5051
return mutable;
5152
}
5253

5354
/**
5455
* Sets whether the message is mutable.
55-
* @param mutable boolean value
56+
* @param mutable boolean value.
5657
*/
5758
public void setMutable(final boolean mutable) {
5859
this.mutable = mutable;
5960
}
6061

6162
/**
6263
* Returns the payload as byte array.
63-
* @return payload The payload byte array
64+
* @return payload The payload byte array.
6465
*/
6566
public byte[] getPayload() {
6667
return payload;
6768
}
6869

6970
/**
7071
* Sets the payload of the message.
71-
* @param payload The payload as byte array
72+
* @param payload The payload as byte array.
7273
*/
7374
public void setPayload(final byte[] payload) {
7475
this.payload = payload;
7576
}
7677

7778
/**
7879
* Returns the quality of service level for the message.
79-
* @return MQTT quality of service level
80+
* @return MQTT quality of service level.
8081
*/
8182
public int getQos() {
8283
return qos;
8384
}
8485

8586
/**
8687
* Sets the quality of service level for the message.
87-
* @param qos MQTT quality of service level
88+
* @param qos MQTT quality of service level.
8889
*/
8990
public void setQos(final int qos) {
9091
this.qos = qos;
9192
}
9293

9394
/**
9495
* Returns whether the message is a retained message.
95-
* @return boolean value
96+
* @return boolean value.
9697
*/
9798
public boolean isRetained() {
9899
return retained;
99100
}
100101

101102
/**
102103
* Sets whether the message is retained.
103-
* @param retained boolean value
104+
* @param retained boolean value.
104105
*/
105106
public void setRetained(final boolean retained) {
106107
this.retained = retained;
107108
}
108109

109110
/**
110111
* Returns whether the message is flagged as duplicate.
111-
* @return boolean value
112+
* @return boolean value.
112113
*/
113114
public boolean getDup() {
114115
return dup;
115116
}
116117

117118
/**
118119
* Flags the message as duplicate.
119-
* @param dup boolean value
120+
* @param dup boolean value.
120121
*/
121122
public void setDup(final boolean dup) {
122123
this.dup = dup;
123124
}
124125

125126
/**
126127
* Returns the message id.
127-
* @return message id
128+
* @return message id.
128129
*/
129130
public int getId() {
130131
return messageId;
131132
}
132133

133134
/**
134135
* Sets the message id.
135-
* @param messageId message id
136+
* @param messageId message id.
136137
*/
137138
public void setId(final int messageId) {
138139
this.messageId = messageId;
139140
}
140141

141142
/**
142143
* Sets the MQTT user properties.
143-
* @param userProperties MQTT user properties
144+
* @param userProperties MQTT user properties.
144145
*/
145146
public void setUserProperties(final List<UserProperty> userProperties) {
146147
this.userProperties = userProperties;
147148
}
148149

149150
/**
150151
* Returns the MQTT user properties.
151-
* @return MQTT user properties
152+
* @return MQTT user properties.
152153
*/
153154
public List<UserProperty> getUserProperties() {
154155
return this.userProperties;
155156
}
157+
158+
/**
159+
* Returns the correlation data for the message.
160+
* @return the correlation data.
161+
*/
162+
public byte[] getCorrelationData() {
163+
return correlationData;
164+
}
165+
166+
/**
167+
* Sets the correlation data for the message.
168+
* @param correlationData the correlation data.
169+
*/
170+
public void setCorrelationData(byte[] correlationData) {
171+
this.correlationData = correlationData;
172+
}
156173
}

mqtt-hivemq/src/main/java/io/micronaut/mqtt/hivemq/client/MqttClientAdapter.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,27 @@
1818
import io.micronaut.mqtt.bind.MqttBindingContext;
1919
import io.micronaut.mqtt.hivemq.bind.MqttMessage;
2020

21+
import java.util.Map;
2122
import java.util.Set;
2223
import java.util.function.Consumer;
24+
import java.util.stream.Collectors;
25+
import java.util.stream.IntStream;
2326

27+
/**
28+
* Common interface for HiveMQ MQTT clients.
29+
*
30+
* @author Sven Kobow
31+
* @since 3.0.0
32+
*/
2433
public interface MqttClientAdapter {
34+
2535
void subscribe(String[] topics, int[] qos, Consumer<MqttBindingContext<MqttMessage>> callback);
2636

37+
default Map<String, Integer> getTopicMap(String[] topics, int[] qos) {
38+
return IntStream.range(0, topics.length).boxed()
39+
.collect(Collectors.toMap(i -> topics[i], i -> qos[i]));
40+
}
41+
2742
void unsubscribe(Set<String> topics);
2843

2944
boolean isConnected();

mqtt-hivemq/src/main/java/io/micronaut/mqtt/hivemq/client/MqttClientFactory.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@
2828
import java.security.cert.Certificate;
2929
import java.security.cert.CertificateException;
3030

31+
/**
32+
* Common interface for MQTT client factories.
33+
*
34+
* @author Sven Kobow
35+
* @since 3.0.3
36+
* @see io.micronaut.mqtt.hivemq.v3.client.Mqtt3ClientFactory
37+
* @see io.micronaut.mqtt.hivemq.v5.client.Mqtt5ClientFactory
38+
*/
3139
public interface MqttClientFactory {
3240

3341
default KeyManagerFactory getKeyManagerFactory(final MqttCertificateConfiguration certConfiguration) throws KeyManagerFactoryCreationException {

mqtt-hivemq/src/main/java/io/micronaut/mqtt/hivemq/client/health/MqttHealthIndicator.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828

2929
import java.util.Collections;
3030

31+
/**
32+
* A {@link HealthIndicator} for HiveMQ MQTT Client.
33+
*
34+
* @author Sven Kobow
35+
* @since 3.0.0
36+
*/
3137
@Requires(property = HealthEndpoint.PREFIX + ".mqtt.client.enabled", value = StringUtils.TRUE)
3238
@Requires(beans = HealthEndpoint.class)
3339
@Singleton

0 commit comments

Comments
 (0)