Hi all,
I’m experiencing some strange ‘features’ while trying to use axon with postgres as a backend db for events.
I’m still a noob into complex ‘application code as infrastructure’ setups with java config/jpa/axon so if anyone has some guidance/ideas where to start looking in to kick it off, would be much appreciated.
My goal is to use spring-boot(1.2.0.RELEASE), axon(2.3.2), postgres(9.3.5) for a axon demo application with a zero xml configuration (only java config).
Problem:
I have correctly configured (as java config) axon and spring-boot and wrote a simple REST application which works as expected only when using mysql. Payload and metadata columns in postgres are not correctly generated (OID instead of bytea)
i’ve tried both using auto generation via “hibernate.hbm2ddl.auto”:“create-drop” and manually modifying the columns but no success. (Manually, there is a lot of indication that casting should occur which i find very strange given that payload/metadata are defined as byte[] originally in AbstractEventEntry).
I’ve dug deep into every github repo that i could find using axon but i cannot find any similar setup to what i want.
PS:
Below, simple data source used by axon (i’ve tried all, including spring original DriverManagerDataSource and org.apache.tomcat.jdbc.pool.DataSource), postgres ddl vs mysql ddl and sample data generated by axon for both. (I’ve even tried to generated metadata via code for the DomainEventEntry but no success).
Thanks a lot,
Marius Rugan
1. Data source used by axon:
HikariConfig config = new HikariConfig();
config.setDriverClassName(“org.postgresql.Driver”);
config.setJdbcUrl(“jdbc:postgresql://localhost:5432/example”);
config.setUsername(“someusername”);
config.setPassword(“somepassword”);
return new HikariDataSource(config);
2A. Postgres example
generated postgres:
CREATE TABLE domainevententry
(
aggregateidentifier VARCHAR(255) NOT NULL,
sequencenumber BIGINT NOT NULL,
type VARCHAR(255) NOT NULL,
eventidentifier VARCHAR(255) NOT NULL,
payloadrevision VARCHAR(255),
payloadtype VARCHAR(255) NOT NULL,
timestamp VARCHAR(255) NOT NULL,
metadata OID,
payload OID NOT NULL,
PRIMARY KEY (aggregateidentifier, sequencenumber, type)
);
CREATE UNIQUE INDEX uk_k5lt6d2792amnloo7q91njp0v ON domainevententry (eventidentifier);
sample data postgres:
timestamp: 2014-12-26T13:06:01.593+01:00
metadata*: 18789 (see below how metadata is altered)
payload: 18790
2B. Mysql example
generated mysql:
CREATE TABLE DomainEventEntry
(
aggregateIdentifier VARCHAR(255) NOT NULL,
sequenceNumber BIGINT NOT NULL,
type VARCHAR(255) NOT NULL,
eventIdentifier VARCHAR(255) NOT NULL,
payloadRevision VARCHAR(255),
payloadType VARCHAR(255) NOT NULL,
timeStamp VARCHAR(255) NOT NULL,
metaData LONGBLOB,
payload LONGBLOB NOT NULL,
PRIMARY KEY (aggregateIdentifier, sequenceNumber, type)
);
CREATE UNIQUE INDEX UK_k5lt6d2792amnloo7q91njp0v ON DomainEventEntry (eventIdentifier);
sample data mysql:
timestamp: 2014-12-26T12:59:26.734+01:00
metadata *: key1value1key2value2
(see below how metadata is altered)
payload: <com.example.axon.variable.VariableCreatedEvent>a7e18cb7-1dce-4a64-b682-6401afe0e586test1test1-payload</com.example.axon.variable.VariableCreatedEvent>
*)Metadata generation:
@CommandHandler
public Variable(VariableCreateCommand command) {
Map<String, String> map = new HashMap<String, String>();
map.put(“key1”, “value1”);
map.put(“key2”, “value2”);
org.axonframework.domain.MetaData metaData = new org.axonframework.domain.MetaData(map);
apply(new VariableCreatedEvent(command.getVariableId(), command.getVariableName(), command.getVariablePayload()), metaData);
}