Skip to content

Commit

Permalink
Adds MemoryPersistence for MQTT feature
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Schnicke <[email protected]>
  • Loading branch information
FrankSchnicke committed Sep 20, 2023
1 parent fe9813f commit 1b2a34a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Expand All @@ -44,7 +45,7 @@ public class MqttAasRepositoryConfiguration {
@ConditionalOnMissingBean
@Bean
public IMqttClient mqttClient(@Value("${mqtt.clientId}") String clientId, @Value("${mqtt.hostname}") String hostname, @Value("${mqtt.port}") int port) throws MqttException {
IMqttClient mqttClient = new MqttClient("tcp://" + hostname + ":" + port, clientId);
IMqttClient mqttClient = new MqttClient("tcp://" + hostname + ":" + port, clientId, new MemoryPersistence());

mqttClient.connect(mqttConnectOptions());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Expand All @@ -47,7 +48,7 @@ public class MqttSubmodelRepositoryConfiguration {
@ConditionalOnMissingBean
@Bean
public IMqttClient mqttClient(@Value("${mqtt.clientId}") String clientId, @Value("${mqtt.hostname}") String hostname, @Value("${mqtt.port}") int port) throws MqttException {
IMqttClient mqttClient = new MqttClient("tcp://" + hostname + ":" + port, clientId);
IMqttClient mqttClient = new MqttClient("tcp://" + hostname + ":" + port, clientId, new MemoryPersistence());

mqttClient.connect(mqttConnectOptions());

Expand Down

0 comments on commit 1b2a34a

Please sign in to comment.