Search code examples
spring-integrationspring-kafka

Spring 5.X web Kafka Integeration using xml configuration (Not Spring boot)


I am trying to setup a kafka consumer on legacy web application using xml configuration that is running Spring 5.2 release project (It is not a spring boot project). After looking up I found a project that sets up the kafka consumer using xml configuration like in here

https://docs.spring.io/spring-kafka/docs/1.3.11.RELEASE/reference/html/_spring_integration.html

However this does not give details on how to connect this with java in a spring web application . All examples are for spring-boot project. I did find out what configuring I need to add to xml

https://github.com/spring-projects/spring-integration-kafka

I also did find an example of Spring web application and kafka but it is for 4.X release and is from 2015.

https://techannotation.wordpress.com/2015/10/26/introduction-to-apache-kafka-using-spring/

Any help on any newer documentation or on how to setup a consumer in java spring web project with xml configuration in 2020 would be appreciated


Solution

  • With Help from Gary Russel and Artem Bilan I was able to figure this out. Since I am using legacy spring application I needed this project and not spring integration project

    https://spring.io/projects/spring-kafka

    I also followed documentation here to setup java config for kafka listener

    https://docs.spring.io/spring-kafka/docs/2.3.12.RELEASE/reference/html/#with-java-configuration

    I used this to figure out how to have both java config and xml config work together

    https://memorynotfound.com/mixing-xml-java-config-spring/

    Here is gist of my implementation that worked

    https://gist.github.com/praveen2710/7dcf1671379ee6db4581436e1225c673