-
Notifications
You must be signed in to change notification settings - Fork 1
Feature - Aggregate event stream inspection #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
stefanmirkovic
merged 9 commits into
main
from
feature/aggregate-event-stream-inspection
Jul 28, 2025
+423
−20
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
afcdcec
Feature - Aggregate event stream inspection
stefanmirkovic 6a21fd0
Change the event information to the serialized format that the user h…
stefanmirkovic c8693cf
Code adjustments based on PR review comments.
stefanmirkovic 0278612
Add SetupPayload DLQ and Domain Events Insights to supported features
stefanmirkovic d7c4465
small addition in createReport fun setup
stefanmirkovic 221a71b
review comments - version bump
stefanmirkovic 0bc0abf
Merge pull request #102 from AxonIQ/feature/propagation-of-the-suppor…
stefanmirkovic 1b518e4
Truncates the string to ensure it doesn't exceed the specified maximu…
stefanmirkovic f748a5d
Merge branch 'main' into feature/aggregate-event-stream-inspection
stefanmirkovic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
console-framework-client-api/src/main/java/io/axoniq/console/framework/api/aggregateApi.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package io.axoniq.console.framework.api | ||
|
|
||
| import java.time.Instant | ||
|
|
||
| data class DomainEventsResult( | ||
| val entityId: String, | ||
| val entityType: String, | ||
| val domainEvents: List<DomainEvent>, | ||
| val page: Int, | ||
| val pageSize: Int, | ||
| val totalCount: Long, | ||
| ) | ||
|
|
||
| data class DomainEvent( | ||
| val sequenceNumber: Long, | ||
| val timestamp: Instant, | ||
| val payloadType: String, | ||
| val payload: String? | ||
| ) | ||
|
|
||
| data class DomainEventsQuery( | ||
| val entityId: String, | ||
| val page: Int = 0, | ||
| val pageSize: Int = 10, | ||
| ) | ||
|
|
||
| data class EntityStateResult( | ||
| val type: String, | ||
| val entityId: String, | ||
| val maxSequenceNumber: Long = 0, | ||
| val state: String, | ||
| ) | ||
|
|
||
| data class EntityStateAtSequenceQuery( | ||
| val type: String, | ||
| val entityId: String, | ||
| val maxSequenceNumber: Long = 0, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...ole-framework-client/src/main/java/io/axoniq/console/framework/DomainEventAccessMode.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package io.axoniq.console.framework; | ||
|
|
||
| public enum DomainEventAccessMode { | ||
| /** | ||
| * Full access: payload is visible and loading domain state is supported. | ||
| */ | ||
| FULL, | ||
|
|
||
| /** | ||
| * Payload is hidden (e.g., masked), but loading domain state is still supported. | ||
| */ | ||
| LOAD_DOMAIN_STATE_ONLY, | ||
|
|
||
| /** | ||
| * Payload is visible, but loading domain state is not supported. | ||
| */ | ||
| PREVIEW_PAYLOAD_ONLY, | ||
|
|
||
| /** | ||
| * No access: payload is hidden and loading domain state is not supported. | ||
| */ | ||
| NONE | ||
| } | ||
80 changes: 80 additions & 0 deletions
80
...client/src/main/java/io/axoniq/console/framework/application/DomainEventStreamProvider.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| package io.axoniq.console.framework.application | ||
|
|
||
| import com.fasterxml.jackson.databind.ObjectMapper | ||
| import org.axonframework.common.ReflectionUtils | ||
| import org.axonframework.config.AggregateConfiguration | ||
| import org.axonframework.config.Configuration | ||
| import org.axonframework.eventhandling.DomainEventMessage | ||
| import org.axonframework.eventhandling.EventMessage | ||
| import org.axonframework.eventsourcing.AggregateFactory | ||
| import org.axonframework.eventsourcing.EventSourcedAggregate | ||
| import org.axonframework.eventsourcing.SnapshotTrigger | ||
| import org.axonframework.eventsourcing.eventstore.AbstractEventStorageEngine | ||
| import org.axonframework.eventsourcing.eventstore.DomainEventStream | ||
| import org.axonframework.modelling.command.Repository | ||
| import org.axonframework.modelling.command.RepositoryProvider | ||
| import org.axonframework.modelling.command.inspection.AggregateModel | ||
|
|
||
| class DomainEventStreamProvider( | ||
| private val configuration: Configuration, | ||
| private val objectMapper: ObjectMapper | ||
| ) { | ||
|
|
||
| fun getDomainEventStream(entityIdentifier: String, firstSequenceNumber: Long = 0): List<DomainEventMessage<*>>? = | ||
| configuration.eventStore() | ||
| .readEvents(entityIdentifier, firstSequenceNumber) | ||
| .iterator() | ||
| .asSequence() | ||
| .toList() | ||
| .takeIf { it.isNotEmpty() } | ||
|
|
||
| fun <T> loadDomainStateAtSequence(type: String, entityIdentifier: String, maxSequenceNumber: Long): String? { | ||
| val entityConfiguration = configuration.modules | ||
| .filterIsInstance<AggregateConfiguration<*>>() | ||
| .firstOrNull { it.aggregateType().simpleName == type } | ||
| ?: throw IllegalArgumentException("No domain entity found for type $type") | ||
|
|
||
| val eventStore = configuration.eventStore() | ||
|
|
||
| val factory: AggregateFactory<T> = entityConfiguration.aggregateFactory() as AggregateFactory<T> | ||
| val model: AggregateModel<T> = entityConfiguration.repository().getPropertyValue<AggregateModel<T>>("aggregateModel") | ||
| ?: throw IllegalArgumentException("No domain entity model found for type $type") | ||
|
|
||
| val stream = readEvents(entityIdentifier) | ||
| val loadingEntity: EventSourcedAggregate<T> = EventSourcedAggregate | ||
| .initialize(factory.createAggregateRoot(entityIdentifier, stream.peek()), | ||
| model, | ||
| eventStore, | ||
| object : RepositoryProvider { | ||
| override fun <T> repositoryFor(aggregateType: Class<T>): Repository<T> { | ||
| return entityConfiguration.repository() as Repository<T> | ||
| } | ||
|
|
||
| }, | ||
| object : SnapshotTrigger { | ||
| override fun eventHandled(p0: EventMessage<*>) { | ||
| // Do nothing | ||
| } | ||
|
|
||
| override fun initializationFinished() { | ||
| // Do nothing | ||
| } | ||
| }) | ||
|
|
||
| loadingEntity.initializeState(stream.filter { it.sequenceNumber <= maxSequenceNumber }) | ||
|
|
||
| return objectMapper.writeValueAsString(loadingEntity.aggregateRoot) | ||
| } | ||
|
|
||
| private fun readEvents(identifier: String, firstSequenceNumber: Long = 0): DomainEventStream = | ||
| configuration.eventStore() | ||
| .getPropertyValue<AbstractEventStorageEngine>("storageEngine") | ||
| ?.readEvents(identifier, firstSequenceNumber) | ||
| ?: throw IllegalStateException("Unable to find AbstractEventStorageEngine in event store") | ||
|
|
||
| @Suppress("UNCHECKED_CAST") | ||
| private inline fun <reified T> Any.getPropertyValue(fieldName: String): T? = | ||
| ReflectionUtils.fieldsOf(this::class.java) | ||
| .firstOrNull { it.name == fieldName } | ||
| ?.let { ReflectionUtils.getMemberValue(it, this) as? T } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.