AxonFramework / ReferenceGuide

The Reference Guide of Axon Framework
Apache License 2.0
29 stars 22 forks source link

Kafka Consumer > KafkaAutoConfiguration seems not to work [axon 3.3.3 + spring boot 2.0.4.RELEASE] #82

Open ghilainm opened 6 years ago

ghilainm commented 6 years ago

I have defined no additional configuration and the application doesn't start by just defining the consumer-group-id as defined the Axon documentation.

Dependencies:

    implementation('org.axonframework:axon-spring-boot-starter:3.3.3')
    implementation('org.apache.kafka:kafka-clients:2.0.0')
    implementation('org.axonframework:axon-kafka:3.3.3')
    + spring-boot 2.0.4.RELEASE

Here is the configuration i have defined in my application.yml

axon:
  kafka:
    default-topic: "my-topic"
    bootstrap-servers: "bootstrap.kafka.svc.cluster.local:9092"
    consumer:
      group-id: "query-consumer"
      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
      value-deserializer: org.apache.kafka.common.serialization.ByteArrayDeserializer

Here are the corresponding starting logs:


***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of method kafkaMessageSource in org.axonframework.boot.autoconfig.KafkaAutoConfiguration required a bean of type 'org.axonframework.kafka.eventhandling.consumer.Fetcher' that could not be found.
    - Bean method 'kafkaFetcher' in 'KafkaAutoConfiguration' not loaded because @ConditionalOnBean (types: org.axonframework.kafka.eventhandling.consumer.ConsumerFactory,org.axonframework.kafka.eventhandling.KafkaMessageConverter; SearchStrategy: all) did not find any beans of type org.axonframework.kafka.eventhandling.KafkaMessageConverter

Action:

Consider revisiting the entries above or defining a bean of type 'org.axonframework.kafka.eventhandling.consumer.Fetcher' in your configuration.

2018-08-13 18:42:36,923 ERROR :  gid: trace= span= [main] o.s.b.d.LoggingFailureAnalysisReporter 

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of method kafkaMessageSource in org.axonframework.boot.autoconfig.KafkaAutoConfiguration required a bean of type 'org.axonframework.kafka.eventhandling.consumer.Fetcher' that could not be found.
    - Bean method 'kafkaFetcher' in 'KafkaAutoConfiguration' not loaded because @ConditionalOnBean (types: org.axonframework.kafka.eventhandling.consumer.ConsumerFactory,org.axonframework.kafka.eventhandling.KafkaMessageConverter; SearchStrategy: all) did not find any beans of type org.axonframework.kafka.eventhandling.KafkaMessageConverter

I could make the application start by redefining this in a class annotated with @Configuration:

@ConditionalOnMissingBean
    @Bean
    public KafkaMessageConverter<String, byte[]> kafkaMessageConverter(
            @Qualifier("eventSerializer") Serializer eventSerializer) {
        return new DefaultKafkaMessageConverter(eventSerializer);
    }

But still nothing is consumed from the Kafka topic (no tracking event processor is started).

I then tried to define to add this in addition to try to register manually an event processor for my KafkaMessageSource but still without any success.

    @Autowired
    public void trackingEventProcessor(
            @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") EventProcessingConfiguration eventProcessingConfiguration,
            KafkaMessageSource kafkaMessageSource) {
        eventProcessingConfiguration.registerTrackingEventProcessorUsingSource("kafka-tracking-event-processor", configuration -> kafkaMessageSource);
    }

    @Bean
    public EventStorageEngine eventStorageEngine(){
        return new InMemoryEventStorageEngine();
    }

    @Bean
    public TokenStore tokenSTore(){
        return new InMemoryTokenStore();
    }

Any clue on how to configure this properly?

nklmish commented 6 years ago

@ghilainm Thanks for creating the issue, the autoconfiguration should be fixed via PR-765, for more details, please refer to this

marinkobabic commented 5 years ago

In the version 3.4 it's still not working properly. Please do the suggested changes here https://github.com/AxonFramework/AxonFramework/issues/710

smcvb commented 5 years ago

@nklmish would you be able to verify @marinkobabic his statement?

marinkobabic commented 5 years ago

You can still use the updated example https://github.com/marinkobabic/axon-kafka-example

On Thu, Nov 1, 2018, 11:05 Steven van Beelen <notifications@github.com wrote:

@nklmish https://github.com/nklmish would you be able to verify @marinkobabic https://github.com/marinkobabic his statement?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AxonFramework/ReferenceGuide/issues/82#issuecomment-434992984, or mute the thread https://github.com/notifications/unsubscribe-auth/ADHSOAO8YG2A6xBHFltdZwWs94tt5LjXks5uqsd0gaJpZM4V62zp .