Skip to content

Commit b14d41b

Browse files
authored
Feature/fail safe subscription handling (#77)
* Handle FiwareIntegrationLayerException in DataImportEventHandler Extended subscriptionService.subscribeAndReset with a try/catch block in the handleDataImportEvent function in DataImportEventHandler.java. This update manages potential FiwareIntegrationLayerExceptions that can occur while subscribing to device measurement notifications. Without this update, the system could crash if such exceptions were thrown, leading to user inconvenience. * Update version in pom.xml Updated the version of the application in the pom.xml file from 8.0.0 to 8.1.0. This step is necessary for the new release, which includes additional exception handling code in DataImportEventHandler for managing potential FiwareIntegrationLayerExceptions, as these could previously lead to system crashes.
1 parent b0729f8 commit b14d41b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<groupId>de.app.5gla</groupId>
1616
<artifactId>api</artifactId>
17-
<version>8.0.0</version>
17+
<version>8.1.0</version>
1818

1919
<properties>
2020
<maven.compiler.source>17</maven.compiler.source>

src/main/java/de/app/fivegla/event/DataImportEventHandler.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package de.app.fivegla.event;
22

33
import de.app.fivegla.fiware.SubscriptionService;
4+
import de.app.fivegla.fiware.api.FiwareIntegrationLayerException;
45
import de.app.fivegla.fiware.model.enums.Type;
56
import de.app.fivegla.integration.agranimo.AgranimoMeasurementImport;
67
import de.app.fivegla.integration.agvolution.AgvolutionMeasurementImport;
@@ -55,8 +56,12 @@ public DataImportEventHandler(SoilScoutMeasurementImport soilScoutMeasurementImp
5556
public void handleDataImportEvent(DataImportEvent dataImportEvent) {
5657
log.info("Handling data import event for manufacturer {}.", dataImportEvent.manufacturer());
5758
if (subscriptionsEnabled) {
58-
subscriptionService.subscribeAndReset(Type.DeviceMeasurement);
59-
log.info("Subscribed to device measurement notifications.");
59+
try {
60+
subscriptionService.subscribeAndReset(Type.DeviceMeasurement);
61+
log.info("Subscribed to device measurement notifications.");
62+
} catch (FiwareIntegrationLayerException e) {
63+
log.error("Error subscribing to device measurement notifications.", e);
64+
}
6065
} else {
6166
log.info("Subscriptions are disabled. Not subscribing to device measurement notifications.");
6267
}

0 commit comments

Comments
 (0)