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