Configuring Custom Table Structure

Hi,

I’m getting started with the Axon framework and have a question regarding how to customize the DB tables for event sourcing.
Currently in my simple ‘account’ application (using CQRS) the following table structure is automatically created.

The event store table is called ‘DOMAIN_EVENT_ENTRY’ and it has some default fields containing META_DATA, PAYLOAD, and other fields that I’m having a difficult time understanding. Can you help me understand what each field means and how can I customize this table (name/structure) for PRODUCTION-grade support?

Hi @mnajar, welcome to the forum!

Below you can find descriptions of columns in the domain_event_entry table:

global_index - the position of an event in the global sequence of events.
event_identifier - the identifier of the serialized event.
meta_data - the serialized data of the MetaData of the event.
payload - the serialized data of the event message’s payload.
payload_revision - the revision of the event payload. Revisions are used for event versioning and can be set using the annotation @Revision("version").
payload_type - the event payload’s fully qualified class name or alias.
time_stamp - the timestamp at which the event was first created.
aggregate_identifier - the identifier of the aggregate to which the event was applied.
sequence_number - the sequence number of the event in the aggregate.
type - the type identifier of the aggregate. Type can be customized in the annotation @Aggregate(type = "type name"). By default, it’s the simple name of the aggregate’s class.

Please note that sequence_number and type columns will contain only default values in state stored aggregates.

Would you be able to share with us what kind of customizations you want to apply to event sourcing tables? We might be able to advise you.

Best regards,
Michal

Thank you very much @mnegacz for your thorough explanation of each table field.
1- How do we ‘de-serialize’ the payload and metadata data in the table for debugging and audit purposes? Or how do we configure the framework to store the data in clear text?
2- Is there a documentation that describes the fields of other tables (e.g. SAGA_ENTRY) just like how you explained them to me?

1- How do we ‘de-serialize’ the payload and metadata data in the table for debugging and audit purposes? Or how do we configure the framework to store the data in clear text?

Events are serialized using a configured serializer. By default, it’s XStreamSerializer, but you can set up a different one to match your needs. Then, serialized data is stored as a large object (LOB) in the database. To get the serialized form in clear text, you can cast it in a query. For example:

SELECT CAST(PAYLOAD AS CLOB) FROM DOMAIN_EVENT_ENTRY;

2- Is there a documentation that describes the fields of other tables (e.g. SAGA_ENTRY) just like how you explained them to me?

Yes, field descriptions are documented in Axon Framework’s JavaDoc. Some of them are inherited from parent classes, so please check them too.

Best regards,
Michal

Hello @mnegacz , @mnajar

Is it possible to cutomize/add new field to domainevent entry table to track audit history of consumer or application id from gateway apis in applications? Any generic ways to store header related data in domain event entry table for each event?

Hey @angela, welcome to the AxonIQ board,

I’m sorry for the late reply. I hope that you’ve already got your answer in the other thread - Adding new field to domainevent entry table to store api gateway header details in event store domainevententry table

Just to let you know, it’s possible to customize the domain_event_entry table by using a SQL migration script or overriding Hibernate’s metadata through XML. However, I believe that the suggestion from the thread above, to use message’s metadata, better suits your use case.

Best regards,
Michal

Hi Michal,
Thanks for the suggestions…As mentioned with metadata able to store audit related info…
Thanks and regards,
Angela kurian