diff --git a/changelog.md b/changelog.md index 80ed351da..934bd0372 100644 --- a/changelog.md +++ b/changelog.md @@ -1,7 +1,8 @@ -### Changelog next version +### 0.17.0 * spring-boot-starter-mongodb no longer autoconfigures itself by just importing the library in the classpath, instead you need to bootstrap by annotating your Spring Boot class with @EnableOccurrent. -* Fixed bug in spring-boot-starter-mongodb module in which it didn't automatically configured MongoDB. -* Domain event subscriptions now accepts metadata as the first parameter, besides just the event. The metadata currently contains the stream version and stream id, which can be useful when building projections. +* Fixed bug in spring-boot-starter-mongodb module in which it didn't automatically configure MongoDB. +* Domain event subscriptions now accepts metadata as the first parameter, besides just the event. The metadata currently contains the stream version and stream id, which can be useful when building projections. +* Fixed a bug in SpringMongoSubscriptionModel in which it didn't restart correctly on non DataAccessException's * Upgraded from Kotlin 1.9.20 to 1.9.22 * Upgraded amqp-client from 5.16.0 to 5.20.0 * Upgraded Spring Boot from 3.1.4 to 3.2.1 diff --git a/subscription/mongodb/spring/blocking/src/main/java/org/occurrent/subscription/mongodb/spring/blocking/SpringMongoSubscriptionModel.java b/subscription/mongodb/spring/blocking/src/main/java/org/occurrent/subscription/mongodb/spring/blocking/SpringMongoSubscriptionModel.java index 9d8695de8..aa9d739bb 100644 --- a/subscription/mongodb/spring/blocking/src/main/java/org/occurrent/subscription/mongodb/spring/blocking/SpringMongoSubscriptionModel.java +++ b/subscription/mongodb/spring/blocking/src/main/java/org/occurrent/subscription/mongodb/spring/blocking/SpringMongoSubscriptionModel.java @@ -333,7 +333,8 @@ private org.springframework.data.mongodb.core.messaging.Subscription registerNew log.debug("Cursor is no longer open for subscription {}, this may happen if you pause a subscription very soon after subscribing.", subscriptionId, throwable); } } else { - log.error("An error occurred for subscription {}", subscriptionId, throwable); + log.error("An error occurred for subscription {}, will restart", subscriptionId, throwable); + restartInternalSubscription(subscriptionId, StartAt.subscriptionModelDefault()); } }); } diff --git a/subscription/mongodb/spring/blocking/src/test/java/org/occurrent/subscription/mongodb/spring/blocking/SpringMongoSubscriptionModelTest.java b/subscription/mongodb/spring/blocking/src/test/java/org/occurrent/subscription/mongodb/spring/blocking/SpringMongoSubscriptionModelTest.java index dbfecfa65..4bf29ea43 100644 --- a/subscription/mongodb/spring/blocking/src/test/java/org/occurrent/subscription/mongodb/spring/blocking/SpringMongoSubscriptionModelTest.java +++ b/subscription/mongodb/spring/blocking/src/test/java/org/occurrent/subscription/mongodb/spring/blocking/SpringMongoSubscriptionModelTest.java @@ -697,6 +697,14 @@ void restarts_subscription_on_DataAccessResourceFailureException() { assertSubscriptionIsRestartedForException(exception); } + @Timeout(value = 20, unit = SECONDS) + @Test + void restarts_subscription_on_non_DataAccessException() { + var exception = new IllegalStateException("Cursor com.mongodb.client.internal.MongoChangeStreamCursorImpl@3ab4fcd8 is not longer open"); + + assertSubscriptionIsRestartedForException(exception); + } + @SuppressWarnings("unchecked") private void assertSubscriptionIsRestartedForException(Exception exception) { // Given