Prashant Shandilya
Prashant Shandilya

Reputation: 71

Axon4 - kafka ext: Query event not invoked

Command side events are getting processed but query (projector) is not invoked. Using axon kafka extension 4.0-RC2.

Please check below code reference.

AxonConfig

import org.springframework.context.annotation.Configuration;

@Configuration
public class AxonConfig {


}

application.yml

server:
  port: 9001
spring:
  application:
    name: Query Application
  datasource:
    url: jdbc:postgresql://localhost:5441/orderdemo
    username: orderdemo
    password: secret
    driver-class-name: org.postgresql.Driver
  jpa:
    properties:
      hibernate:
        dialect: org.hibernate.dialect.PostgreSQL95Dialect
        jdbc:
          lob:
            non_contextual_creation: true
        hbm2ddl.auto: update
        implicit_naming_strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
        physical_naming_strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy    

axon:
  eventhandling:
    processors:
      query:
        mode: tracking
        source: kafkaMessageSource
  kafka:
    default-topic: axon-events
    consumer:
      group-id: query-group
      bootstrap-servers: localhost:9092

Upvotes: 0

Views: 72

Answers (1)

Steven
Steven

Reputation: 7275

For this configuration to work, the classes which contain the @EventHandler annotated functions you want to be called for handling the events from Kafka, needs to be part of the processing group query.

This requirement follows from the configuration pattern you've chosen, where "axon. eventhandling.processors.query" defines the Processing Group you want to configure. To specify the Processing Group, I think the easiest approach is to add the @ProcessingGroup annotation to your Event Handling Class. In the annotation, you have to provide the name of the Processing Group, which needs to correspond with what you've set int he configuration file.

Lastly, I would suggest to use a different name than query for your Processing Group. Something more specific to the query model that Event Handler updates would seem more in place to me.

Hope this helps!

Upvotes: 2

Related Questions