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.BlockingSubscription
toorg.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.ReactorSubscription
has now been renamed toorg.occurrent.subscription.api.reactor.SubscriptionModel
). - Derivatives of
org.occurrent.subscription.api.blocking.BlockingSubscription
such asPositionAwareBlockingSubscription
has been renamed toorg.occurrent.subscription.api.blockking.PositionAwareSubscriptionModel
. - Derivatives of the reactor counterpart,
org.occurrent.subscription.api.reactor.PositionAwareReactorSubscription
has been renamedto
, such as has been renamed toorg.occurrent.subscription.api.reactor.PositionAwareSubscriptionModel
. org.occurrent.subscription.util.blocking.catchup.subscription.CatchupSubscriptionModelConfig
has been renamed toorg.occurrent.subscription.blocking.catchup.CatchupSubscriptionModelConfig
.org.occurrent.subscription.util.blocking.catchup.subscription.CatchupSubscriptionModel
has been renamed toorg.occurrent.subscription.blocking.catchup.CatchupSubscriptionModel
.org.occurrent.subscription.util.blocking.AutoPersistingSubscriptionModelConfig
has been renamed toorg.occurrent.subscription.blocking.durable.DurableSubscriptionModelConfig
.org.occurrent.subscription.util.blocking.BlockingSubscriptionWithAutomaticPositionPersistence
has been renamed toorg.occurrent.subscription.blocking.durable.DurableSubscriptionModel
.org.occurrent.subscription.mongodb.nativedriver.blocking.BlockingSubscriptionForMongoDB
has been renamed toNativeMongoSubscriptionModel
.org.occurrent.subscription.mongodb.nativedriver.blocking.BlockingSubscriptionPositionStorageForMongoDB
has been renamed toNativeMongoSubscriptionPositionStorage
.- Removed
org.occurrent.subscription.mongodb.nativedriver.blocking.BlockingSubscriptionWithPositionPersistenceInMongoDB
. Use anorg.occurrent.subscription.blocking.DurableSubscriptionModel
from moduleorg.occurrent:durable-subscription
instead. org.occurrent.subscription.mongodb.spring.blocking.MongoDBSpringSubscription
has been renamed toSpringMongoSubscription
.org.occurrent.subscription.mongodb.spring.blocking.SpringBlockingSubscriptionForMongoDB
has been renamed toSpringMongoSubscription
.org.occurrent.subscription.mongodb.spring.blocking.SpringMongoDBSubscriptionPositionStorage
has been renamed toSpringMongoSubscriptionPositionStorage
.org.occurrent.subscription.mongodb.spring.reactor.SpringReactorSubscriptionForMongoDB
has been renamed toReactorMongoSubscription
.org.occurrent.subscription.mongodb.spring.reactor.SpringReactorSubscriptionPositionStorageForMongoDB
has been renamed toReactorSubscriptionPositionStorage
.org.occurrent.subscription.util.reactor.ReactorSubscriptionWithAutomaticPositionPersistence
has been renamed toorg.occurrent.subscription.reactor.durable.ReactorDurableSubscriptionModel
.org.occurrent.subscription.util.reactor.ReactorSubscriptionWithAutomaticPositionPersistenceConfig
has been renamed toorg.occurrent.subscription.reactor.durable.ReactorDurableSubscriptionConfig
.org.occurrent.eventstore.mongodb.spring.reactor.SpringReactorMongoEventStore
has been renamed toReactorMongoEventStore
since “Spring” is implicit.org.occurrent.subscription.mongodb.MongoDBFilterSpecification
has been renamed toMongoFilterSpecification
.org.occurrent.subscription.mongodb.MongoDBFilterSpecification.JsonMongoDBFilterSpecification
has been renamed toMongoJsonFilterSpecification
.org.occurrent.subscription.mongodb.MongoDBFilterSpecification.BsonMongoDBFilterSpecification
has been renamed toMongoBsonFilterSpecification
.org.occurrent.subscription.mongodb.internal.MongoDBCloudEventsToJsonDeserializer
has been renamed toMongoCloudEventsToJsonDeserializer
.org.occurrent.subscription.mongodb.internal.MongoDBCommons
has been renamed toMongoCommons
.org.occurrent.subscription.mongodb.MongoDBOperationTimeBasedSubscriptionPosition
has been renamed toMongoOperationTimeSubscriptionPosition
.org.occurrent.subscription.mongodb.MongoDBResumeTokenBasedSubscriptionPosition
has been renamed toMongoResumeTokenSubscriptionPosition
.org.occurrent.eventstore.mongodb.internal.OccurrentCloudEventMongoDBDocumentMapper
has been renamed toOccurrentCloudEventMongoDocumentMapper
.org.occurrent.eventstore.mongodb.spring.blocking.SpringBlockingMongoEventStore
has been renamed toSpringMongoEventStore
.- Renamed module
org.occurrent:subscription-util-blocking-catchup-subscription
toorg.occurrent:catchup-subscription
. - Renamed module
org.occurrent:subscription-util-blocking-automatic-position-persistence
toorg.occurrent:durable-subscription
. - Renamed module
org.occurrent:subscription-util-reactor-automatic-position-persistence
toorg.occurrent:reactor-durable-subscription
. - Moved
org.occurrent.application.converter.implementation.GenericCloudEventConverter
toorg.occurrent.application.converter.generic.GenericCloudEventConverter
. - Moved
org.occurrent.application.service.blocking.implementation.GenericApplicationService
toorg.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
InMemoryEventStore
constructor 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-inmemory
and then instantiate it using:InMemorySubscriptionModel inMemorySubscriptionModel = new InMemorySubscriptionModel(); InMemoryEventStore inMemoryEventStore = new InMemoryEventStore(inMemorySubscriptionModel); inMemorySubscriptionModel.subscribe("subscription1", System.out::println);
- Renamed groupId
org.occurrent.inmemory
toorg.occurrent
for consistency. This means that you should depend on moduleorg.occurrent:eventstore-inmemory
instead oforg.occurrent.inmemory:eventstore-inmemory
when using the in-memory event store. - Added support for querying the in-memory event store (all fields expect the “data” field works)
- Changed from
Executor
toExecutorService
inNativeMongoSubscriptionModel
in theorg.occurrent:subscription-mongodb-native-blocking
module. - Added a
@PreDestroy
annotation to theshutdown
method in theNativeMongoSubscriptionModel
implementation so that, if you’re frameworks such as Spring Boot, you don’t need to explicitly call theshutdown
method when stopping. - Added partial extension functions for
List<DomainEvent>
, import from thepartial
method fromorg.occurrent.application.composition.command
.