Marc
Marc

Reputation: 113

How to query axon aggregates

Is there a way to see the current state of the aggregates stored in axon?

Our application uses a Oracle backed axon event store. I tried querying the domainevententry and snapshotevententry tables, but they are empty.

Upvotes: 0

Views: 1162

Answers (1)

Steven
Steven

Reputation: 7275

Is there a way to see the current state of the aggregates stored in axon?

In short, yes, although it is not recommended. Granted, if you are planning to employ CQRS. CQRS, or Command-Query Responsibility Separation, dictates that the Command Model and the Query Model are separate.

The aggregate support Axon delivers supplies an easy means to construct a Command Model. As the name suggests, it's intended for commands. On the flip side, you have Query Models, which are designed for queries. AxonIQ has this to say on CQRS; maybe that clarifies some things.

I tried querying the domainevententry and snapshotevententry tables, but they are empty.

That's interesting on its own account! When you publish events in Axon, either through the AggregateLifecycle#apply(Object...) or EventGateway#publish(Object...) method, the published event should end up in your domain_event_entry table. If that's not the case, then either your JPA/JDBC configuration has a misser or some other exceptions occurring in your application.

Would you be able to update your issue with samples of your configuration and/or stack traces that you are seeing?

Replaying production issues locally

What I've done in the past to be able to replay behavior occurring in a production environment is by loading the Aggregate's event stream from that environment into a local dev/test event store. To be able to query this, you only need the aggregate identifier. As the aggregate identifier is indexed, retrieving all events for a specific aggregate (differently named, the aggregate stream) is straightforward.

By doing so, I could run the application locally to flow through the aggregate step-by-step. This gave the benefit of knowing exactly which event caused what state change, leading to the problematic scenario.

However, why your events are not present in your domainevententry is unclear to me. If you're still facing issues with that, I still recommend that you update the question with more specifics on your project.

Upvotes: 1

Related Questions