Skip to content

Commit

Permalink
Adding equals/hashcode and toString to SpringMongoSubscriptionModel, …
Browse files Browse the repository at this point in the history
…this is useful in certain debug logging scenarios
  • Loading branch information
johanhaleby committed Jan 17, 2025
1 parent 6ce1f86 commit 1809cb5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### Changelog next version
* Converted `org.occurrent.subscription.OccurrentSubscriptionFilter` from a Java class to a record. This means that the `public final` filter instance field is now a record property. So if you ever used `occurrentSubscriptionFilter.filter` to access the underlying filter, you now need to do `occurrentSubscriptionFilter.filter()` instead.
* Fixed a bug in MongoLeaseCompetingConsumerStrategySupport in which it was not marked a running on start. This could affect retries of certain competing consumer errors.
* Adding equals/hashcode and toString to SpringMongoSubscriptionModel, this is useful in certain debug logging scenarios

### 0.19.7 (2024-11-01)
* Implemented "in" conditions so you can now do e.g. `subscriptionModel.subscribe("id", OccurrentSubscriptionFilter.filter(Filter.streamVersion(Condition.in(12L, 14L))`. There's also a Kotlin extension function, `isIn`, which can be imported from `org.occurrent.condition.isIn`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,4 +444,31 @@ private static void logDebug(String message, Object... params) {
log.debug(message, params);
}
}


@Override
public boolean equals(Object o) {
if (!(o instanceof SpringMongoSubscriptionModel that)) return false;
return restartSubscriptionsOnChangeStreamHistoryLost == that.restartSubscriptionsOnChangeStreamHistoryLost && shutdown == that.shutdown && Objects.equals(eventCollection, that.eventCollection) && Objects.equals(messageListenerContainer, that.messageListenerContainer) && Objects.equals(runningSubscriptions, that.runningSubscriptions) && Objects.equals(pausedSubscriptions, that.pausedSubscriptions) && timeRepresentation == that.timeRepresentation && Objects.equals(mongoOperations, that.mongoOperations) && Objects.equals(retryStrategy, that.retryStrategy);
}

@Override
public int hashCode() {
return Objects.hash(eventCollection, messageListenerContainer, runningSubscriptions, pausedSubscriptions, timeRepresentation, mongoOperations, retryStrategy, restartSubscriptionsOnChangeStreamHistoryLost, shutdown);
}

@Override
public String toString() {
return new StringJoiner(", ", SpringMongoSubscriptionModel.class.getSimpleName() + "[", "]")
.add("eventCollection='" + eventCollection + "'")
.add("messageListenerContainer=" + messageListenerContainer)
.add("runningSubscriptions=" + runningSubscriptions)
.add("pausedSubscriptions=" + pausedSubscriptions)
.add("timeRepresentation=" + timeRepresentation)
.add("mongoOperations=" + mongoOperations)
.add("retryStrategy=" + retryStrategy)
.add("restartSubscriptionsOnChangeStreamHistoryLost=" + restartSubscriptionsOnChangeStreamHistoryLost)
.add("shutdown=" + shutdown)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ public boolean isPaused(String subscriptionId) {
public synchronized Subscription resumeSubscription(String subscriptionId) {
logDebug("Trying to resume CompetingConsumer subscription (subscriptionId={})", subscriptionId);
if (isRunning(subscriptionId)) {
logDebug("Subscription already is running, cannot resume (subscriptionId={}, delegate={})", subscriptionId, delegate.toString());
throw new IllegalArgumentException("Subscription " + subscriptionId + " is not paused");
}

Expand Down

0 comments on commit 1809cb5

Please sign in to comment.