Occurrent 0.5.0 is now available. It contains a new subscription api, a much improved in-memory event store (that now supports queries), as well as in-memory subscription component. Several components have been also moved and switched name (see below). Most noteworthy is that “Subscription” has been renamed to “SubscriptionModel”. It was very confusing in the previous version since before you created a subscription (instance) from a subscription, but they both had the same name. Now you create a subscription (instance) from a subscription model instead. For example:
InMemorySubscriptionModel inMemorySubscriptionModel = new InMemorySubscriptionModel();
InMemoryEventStore inMemoryEventStore = new InMemoryEventStore(inMemorySubscriptionModel);
inMemorySubscriptionModel.subscribe("subscription1", System.out::println);
This version also introduces a new subscription dsl for Java and Kotlin (depend on org.occurrent:subscription-dsl).
It allows you to configure subscriptions in a more concise way, for example you can do like this in Kotlin:
val subscriptionModel = SpringMongoSubscriptionModel(..)
val cloudEventConverter = GenericCloudEventConverter<DomainEvent>(..)
subscriptions(subscriptionModel, cloudEventConverter) {
subscribe<GameStarted>("id1") { gameStarted ->
log.info("Game was started $gameStarted")
}
subscribe<GameWon, GameLost>("id2") { domainEvent ->
log.info("Game was either won or lost: $domainEvent")
}
subscribe("everything") { domainEvent ->
log.info("I subscribe to every event: $domainEvent")
}
}
In Java, you can do like this:
var subscriptions = new Subscriptions<DomainEvent>();
subscriptions.subscribe("id1", GameStarted.class, event -> System.out.println("Event was received: " + event.getClass().getSimpleName()));
Here are all changes:
- Renamed
org.occurrent.subscription.api.blocking.BlockingSubscriptiontoorg.occurrent.subscription.api.blocking.SubscriptionModel. The reason for this is that it was previously very confusing to differentiate between aorg.occurrent.subscription.api.blocking.BlockingSubscription(where you start/cancel subscriptions) and aorg.occurrent.subscription.api.blocking.Subscription(the actual subscription instance). The same thinking has been applied to the reactor counterparts as well (org.occurrent.subscription.api.reactor.ReactorSubscriptionhas now been renamed toorg.occurrent.subscription.api.reactor.SubscriptionModel). - Derivatives of
org.occurrent.subscription.api.blocking.BlockingSubscriptionsuch asPositionAwareBlockingSubscriptionhas been renamed toorg.occurrent.subscription.api.blockking.PositionAwareSubscriptionModel. - Derivatives of the reactor counterpart,
org.occurrent.subscription.api.reactor.PositionAwareReactorSubscriptionhas been renamedto, such as has been renamed toorg.occurrent.subscription.api.reactor.PositionAwareSubscriptionModel. org.occurrent.subscription.util.blocking.catchup.subscription.CatchupSubscriptionModelConfighas been renamed toorg.occurrent.subscription.blocking.catchup.CatchupSubscriptionModelConfig.org.occurrent.subscription.util.blocking.catchup.subscription.CatchupSubscriptionModelhas been renamed toorg.occurrent.subscription.blocking.catchup.CatchupSubscriptionModel.org.occurrent.subscription.util.blocking.AutoPersistingSubscriptionModelConfighas been renamed toorg.occurrent.subscription.blocking.durable.DurableSubscriptionModelConfig.org.occurrent.subscription.util.blocking.BlockingSubscriptionWithAutomaticPositionPersistencehas been renamed toorg.occurrent.subscription.blocking.durable.DurableSubscriptionModel.org.occurrent.subscription.mongodb.nativedriver.blocking.BlockingSubscriptionForMongoDBhas been renamed toNativeMongoSubscriptionModel.org.occurrent.subscription.mongodb.nativedriver.blocking.BlockingSubscriptionPositionStorageForMongoDBhas been renamed toNativeMongoSubscriptionPositionStorage.- Removed
org.occurrent.subscription.mongodb.nativedriver.blocking.BlockingSubscriptionWithPositionPersistenceInMongoDB. Use anorg.occurrent.subscription.blocking.DurableSubscriptionModelfrom moduleorg.occurrent:durable-subscriptioninstead. org.occurrent.subscription.mongodb.spring.blocking.MongoDBSpringSubscriptionhas been renamed toSpringMongoSubscription.org.occurrent.subscription.mongodb.spring.blocking.SpringBlockingSubscriptionForMongoDBhas been renamed toSpringMongoSubscription.org.occurrent.subscription.mongodb.spring.blocking.SpringMongoDBSubscriptionPositionStoragehas been renamed toSpringMongoSubscriptionPositionStorage.org.occurrent.subscription.mongodb.spring.reactor.SpringReactorSubscriptionForMongoDBhas been renamed toReactorMongoSubscription.org.occurrent.subscription.mongodb.spring.reactor.SpringReactorSubscriptionPositionStorageForMongoDBhas been renamed toReactorSubscriptionPositionStorage.org.occurrent.subscription.util.reactor.ReactorSubscriptionWithAutomaticPositionPersistencehas been renamed toorg.occurrent.subscription.reactor.durable.ReactorDurableSubscriptionModel.org.occurrent.subscription.util.reactor.ReactorSubscriptionWithAutomaticPositionPersistenceConfighas been renamed toorg.occurrent.subscription.reactor.durable.ReactorDurableSubscriptionConfig.org.occurrent.eventstore.mongodb.spring.reactor.SpringReactorMongoEventStorehas been renamed toReactorMongoEventStoresince “Spring” is implicit.org.occurrent.subscription.mongodb.MongoDBFilterSpecificationhas been renamed toMongoFilterSpecification.org.occurrent.subscription.mongodb.MongoDBFilterSpecification.JsonMongoDBFilterSpecificationhas been renamed toMongoJsonFilterSpecification.org.occurrent.subscription.mongodb.MongoDBFilterSpecification.BsonMongoDBFilterSpecificationhas been renamed toMongoBsonFilterSpecification.org.occurrent.subscription.mongodb.internal.MongoDBCloudEventsToJsonDeserializerhas been renamed toMongoCloudEventsToJsonDeserializer.org.occurrent.subscription.mongodb.internal.MongoDBCommonshas been renamed toMongoCommons.org.occurrent.subscription.mongodb.MongoDBOperationTimeBasedSubscriptionPositionhas been renamed toMongoOperationTimeSubscriptionPosition.org.occurrent.subscription.mongodb.MongoDBResumeTokenBasedSubscriptionPositionhas been renamed toMongoResumeTokenSubscriptionPosition.org.occurrent.eventstore.mongodb.internal.OccurrentCloudEventMongoDBDocumentMapperhas been renamed toOccurrentCloudEventMongoDocumentMapper.org.occurrent.eventstore.mongodb.spring.blocking.SpringBlockingMongoEventStorehas been renamed toSpringMongoEventStore.- Renamed module
org.occurrent:subscription-util-blocking-catchup-subscriptiontoorg.occurrent:catchup-subscription. - Renamed module
org.occurrent:subscription-util-blocking-automatic-position-persistencetoorg.occurrent:durable-subscription. - Renamed module
org.occurrent:subscription-util-reactor-automatic-position-persistencetoorg.occurrent:reactor-durable-subscription. - Moved
org.occurrent.application.converter.implementation.GenericCloudEventConvertertoorg.occurrent.application.converter.generic.GenericCloudEventConverter. - Moved
org.occurrent.application.service.blocking.implementation.GenericApplicationServicetoorg.occurrent.application.service.blocking.generic.GenericApplicationService. -
Added a new “Subscription DSL” module that adds a domain event specific abstraction on-top of the existing subscription model api’s. This DSL makes it easier to create subscriptions that are using domain events instead of cloud events. The module is called
org.occurrent:subscription-dsl. For example:val subscriptionModel = SpringMongoSubscriptionModel(..) val cloudEventConverter = GenericCloudEventConverter<DomainEvent>(..) // Subscription DSL subscriptions(subscriptionModel, cloudEventConverter) { subscribe<GameStarted>("id1") { gameStarted -> log.info("Game was started $gameStarted") } subscribe<GameWon, GameLost>("id2") { domainEvent -> log.info("Game was either won or lost: $domainEvent") } subscribe("everything") { domainEvent -> log.info("I subscribe to every event: $domainEvent") } } - Implemented ability to delete cloud events by a filter in the in-memory event store.
- Added “listener” support to the in-memory event store. This means that you can supply a “listener” (a consumer) to the
InMemoryEventStoreconstructor that will be invoked (synchronously) after new events have been written. This is mainly useful to allow in-memory subscription models. -
Added an in-memory subscription model that can be used to subscribe to events from the in-memory event store. Add module
org.occurrent:subscription-inmemoryand then instantiate it using:InMemorySubscriptionModel inMemorySubscriptionModel = new InMemorySubscriptionModel(); InMemoryEventStore inMemoryEventStore = new InMemoryEventStore(inMemorySubscriptionModel); inMemorySubscriptionModel.subscribe("subscription1", System.out::println); - Renamed groupId
org.occurrent.inmemorytoorg.occurrentfor consistency. This means that you should depend on moduleorg.occurrent:eventstore-inmemoryinstead oforg.occurrent.inmemory:eventstore-inmemorywhen using the in-memory event store. - Added support for querying the in-memory event store (all fields expect the “data” field works)
- Changed from
ExecutortoExecutorServiceinNativeMongoSubscriptionModelin theorg.occurrent:subscription-mongodb-native-blockingmodule. - Added a
@PreDestroyannotation to theshutdownmethod in theNativeMongoSubscriptionModelimplementation so that, if you’re frameworks such as Spring Boot, you don’t need to explicitly call theshutdownmethod when stopping. - Added partial extension functions for
List<DomainEvent>, import from thepartialmethod fromorg.occurrent.application.composition.command.