Adam Bernau
Adam Bernau

Reputation: 759

Axon: Use AxonServer instead of defined JPA datasource in a Spring Boot application

I would like to use AxonServer as an EventStore in a Spring Boot application, but Axon auto-configuration uses JPA datasource, if defined. I don't know how to force Axon auto-configuration to use AxonServer instead of JPA?

Update:

With amazing advice from Steven (thanks a lot), I managed to little bit clarify what I would like to ask:

If I define a datasource and JPA entries in Spring Boot application config as in the example below, the tables token_entry, saga_entry, etc. are then created in the database. I would like to set AXON not to use this datasource and not create any tables in it.

application.yml

spring:
  datasource:
    username: test
    password: test
    url: "jdbc:postgresql://localhost:5432/abc"
    driver-class-name: org.postgresql.Driver
  jpa:
    database: POSTGRESQL
    database-platform: org.hibernate.dialect.PostgreSQL9Dialect
    hibernate:
      ddl-auto: update
    properties:
      hibernate:
        temp:
          use_jdbc_metadata_defaults: false

Upvotes: 2

Views: 1137

Answers (1)

Steven
Steven

Reputation: 7275

The answer relies a bit on what version of Axon Framework you are using. If you use 4.0 and above, the auto configuration will look for an Axon Server instance in your environment. You will thus not have to force it at all.

If you are however using 3.3.x or 3.4.x, you will have to leverage the Axon Hub Client. More specifically, the axonhub-spring-boot-autoconfigure dependency should be included.

However, I would recommend upgrading to the latest Axon Framework 4 release, as feature development only takes place there at the moment.

Upvotes: 2

Related Questions