Hi all,
currently the Axon setup is running with Java 11, Spring Boot 2.7.14 and axon-spring-boot-starter 4.8.0.
I try to migrate to Java 17 and Spring Boot 3.1.2 using the official upgrading guide: Upgrading to 4.7 - Axon Reference Guide
What I’ve changed:
- all javax imports are adjusted to jakarta
- new sequences has been created
dt.domain_event_entry_seq
and initialized with the old value +1 of the deprecatedhibernate_sequence
The architecture overview: the application is consuming messages from eventhub and publishing them on the Axon EventBus as GenericEventMessage. We are using the Event Store (Azure SQL DB) to store the events and some Eventhandler (PooledStreamingEventProcessor based) to project the events into variouse query models.
No magic.
The problems that occure with Java 17 + SB 3.1.2 + Axon (4.7.6, 4.8.0 and 4.8.1):
although the db sequence dt.domain_event_entry_seq
has been initialized with the deprecated hibernate_sequence value +1, the events can’t be stored to the event store because of primary key viaolation.
2023-08-21 11:37:52.430 org.springframework.kafka.KafkaListenerEndpointContainer#0-0-C-1 [ERROR] [KafkaMessageListenerContainer] - Error handler threw an exception
com.microsoft.sqlserver.jdbc.SQLServerException: Violation of PRIMARY KEY constraint 'PK__domain_e__30BB9782A875E41D'. Cannot insert duplicate key in object 'dt.domain_event_entry'. The duplicate key value is (864145026).
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:265)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1676)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:620)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:540)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7620)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:3916)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:268)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:242)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:486)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:275)
... 62 common frames omitted
Wrapped by: org.hibernate.exception.ConstraintViolationException: could not execute statement [Violation of PRIMARY KEY constraint 'PK__domain_e__30BB9782A875E41D'. Cannot insert duplicate key in object 'dt.domain_event_entry'. The duplicate key value is (864145026).]
domain_event_entry DDL:
CREATE TABLE dt.domain_event_entry (
global_index BIGINT NOT NULL
PRIMARY KEY,
event_identifier NVARCHAR(255) NOT NULL,
meta_data VARBINARY(MAX),
payload VARBINARY(MAX) NOT NULL,
payload_revision NVARCHAR(255),
payload_type NVARCHAR(255) NOT NULL,
time_stamp NVARCHAR(255) NOT NULL,
aggregate_identifier NVARCHAR(255) NOT NULL,
sequence_number BIGINT NOT NULL,
type NVARCHAR(255),
partner_id AS CONVERT([varchar](36), JSON_VALUE(CONVERT([varchar](MAX), [payload]), '$.partnerId')),
event_uuid AS CONVERT([uniqueidentifier], JSON_VALUE(CONVERT([varchar](MAX), [payload]), '$.eventUID'))
)
What am I missing? Happy to get some feedback.
Best Regards