Sumanth Kumar Mora
Sumanth Kumar Mora

Reputation: 697

DOMAIN_EVENT_ENTRY table is not created by AXON

I have my Aggregate GiftCard defined like,

@Data
@NoArgsConstructor
@Aggregate
public class GiftCard {

    @AggregateIdentifier
    private String id;

    private int remainingValue;

    @CommandHandler
    public GiftCard(IssueCardCommand cmd) {
        apply(new CardIssuedEvent(cmd.getCardId(), cmd.getAmount()));
    }

    @CommandHandler
    public GiftCard(TempCommand cmd) {
        apply(new CardIssuedEvent(cmd.getCardId(), cmd.getAmount()));
    }

    @EventSourcingHandler
    public void on(CardIssuedEvent event) {
        this.id = event.getCardId();
        this.remainingValue = event.getAmount();
    }
}

And I dispatch IssueCardCommand from controller.

public String createGreeting(@PathVariable String cardNumber) {
    IssueCardCommand issueCardCommand = new IssueCardCommand(cardNumber, 100);
    commandGateway.sendAndWait(issueCardCommand, 500L, TimeUnit.MILLISECONDS);
    return "Hey";
}

I can confirm that event is dispatched by looking at http://localhost:8024/#query in AxonServer.

I want to do EventSourcing and had setup in-memory H2 database.

    compile group: 'org.projectlombok', name: 'lombok', version: '1.18.6'

    compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.1.3.RELEASE'
    implementation 'org.axonframework:axon:4.1.1'
    implementation 'org.axonframework:axon-spring-boot-starter:4.1.1'
    testCompile group: 'junit', name: 'junit', version: '4.12'

    compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '2.1.4.RELEASE'
    runtime group: 'com.h2database', name: 'h2', version: '1.4.199'

When I look at h2-console after dispatching event, I am not able to find the that event in database. Many articles were written saying, it will be stored in DOMAIN_EVENT_ENTRY table. Unfortunately, in my case I can't event find that table. I can only see ASSOCIATION_VALUE_ENTRY, SAGA_ENTRY, TOKEN_ENTRY these 3 tables.

This is how pretty much my setup looks like. Commands and Events are written for learning/practice purpose (you can ignore business context and best practices at this moment)

Upvotes: 5

Views: 1554

Answers (1)

Allard
Allard

Reputation: 2910

The project was recently updated to only have these tables created, when they're actually used. If you don't use the EmbeddedEventStore with a JPAStorageEngine, then these tables aren't created. In your setup, you seem to be using AxonServer (which is the default unless you exclude the axon-server-connector dependency). In that case, Events are stored in AxonServer.

So what you're seeing is correct and expected behavior.

Upvotes: 5

Related Questions