Hi!
We experimented with the following Table-Definition:
CREATE TABLE "DB2INST1"."DOMAIN_EVENT_ENTRY" (
"GLOBAL_INDEX" BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY (
START WITH +1
INCREMENT BY +1
MINVALUE +1
MAXVALUE +9223372036854775807
NO CYCLE
CACHE 20
NO ORDER ) ,
"EVENT_IDENTIFIER" VARCHAR(255 OCTETS) NOT NULL ,
"META_DATA" BLOB(10000) LOGGED NOT COMPACT ,
"PAYLOAD" BLOB(10000) LOGGED NOT COMPACT NOT NULL ,
"PAYLOAD_REVISION" VARCHAR(255 OCTETS) ,
"PAYLOAD_TYPE" VARCHAR(255 OCTETS) NOT NULL ,
"TIME_STAMP" VARCHAR(255 OCTETS) NOT NULL ,
"AGGREGATE_IDENTIFIER" VARCHAR(255 OCTETS) NOT NULL ,
"SEQUENCE_NUMBER" BIGINT NOT NULL GENERATED ALWAYS AS (GLOBAL_INDEX) ,
"TYPE" VARCHAR(255 OCTETS) )
IN "USERSPACE1"
ORGANIZE BY ROW;
So we would like to simply let the database generate the sequence number for us.
We know that the business logic has to be able to deal with this. But for us, this is the case.
Everything works fine until we enable Snapshotting: Afterwards, it can happen that events are
contained in the snapshot and then be applied once more on top of it.
So it seems like the snapshot gets sorted into the wrong position of the event stream.
Or the snapshot is on the right position but has too many events contained.
We are using the JpaEventStorageEngine with a slightly modified DomainEventEntry:
@Entity
@Table(name = "DOMAIN_EVENT_ENTRY")
@AttributeOverride(name = "sequenceNumber", column = @Column(name = "sequenceNumber", insertable = false, updatable = false))
public class NonStrictDomainEventEntry extends AbstractSequencedDomainEventEntry<byte[]> {
This way the sequenceNumber isn't written to the store anymore, so that the database can generate
it on their own.
Any idea why the snapshot seems to be misordered in the event stream?
Thanks in advance,
Dirk