Upgrading Springtime Analysis Other individuals was not effortless, however, which had little to do with Spring Analysis People in itself

Upgrading Springtime Analysis Other individuals was not effortless, however, which had little to do with Spring Analysis People in itself

Having said that, it might not add up to even do this. I cannot inquire the fresh new builders as to the reasons it was done this ways, they aren’t here any more. This project’s facts can only learn with regards to Git record.

Lessons read updating Spring Investigation Rest

I suspect we are having fun with Springtime Research People completely wrong, wrongly mix WebMVC principles. Whenever we had not done this right away, anything would have work on much simpler.

Our company is now finished with the fresh new Springtime Studies Other people migration. It’s time to circulate to our second Springtime component, Springtime Kafka.

Springtime Kafka

Spring Kafka, or rather Spring season to possess Apache Kafka , is a fantastic treatment for have fun with Kafka on your Spring strategies. It provides effortless-to-play with themes to own sending texts and typical Spring annotations to own ingesting texts.

Configuring brand new customers

step one [ERROR] coffee.lang.IllegalStateException: Don't load ApplicationContext 2 3 For the reason that: org.springframework.beans.warehouse.BeanCreationException: Mistake undertaking bean having name 'consumerFactory' defined in category path financial support [ de / software / config / KafkaConsumerConfig . class ]: cuatro 5 Caused by: java . lang . NullPointerException six at java . legs / java . util . concurrent . ConcurrentHashMap . putVal ( ConcurrentHashMap . java: 1011 ) 7 at java . base / java . util . concurrent . ConcurrentHashMap . init >( ConcurrentHashMap . java: 852 ) 8 at org . springframework . kafka . center . DefaultKafkaConsumerFactory . init >( DefaultKafkaConsumerFactory . java: 125 ) 9 at org . springframework . kafka . core . DefaultKafkaConsumerFactory . init >( DefaultKafkaConsumerFactory . java: 98 ) 10 at de . app . config . KafkaConsumerConfig . consumerFactory ( AbstractKafkaConsumerConfig . java: 120 ) 

It turns out, we had been configuring the consumerConfigs bean and setting null values in its properties. The following change from HashMap to ConcurrentHashMap means we can no longer configure null values. We refactored our code and now tests are green. Easy-peasy.

Kafka messages that have JsonFilter


1 [ERROR] org .apache .kafka mon .mistakes .SerializationException : Normally 't serialize study [Skills [payload=MyClass(Id=201000000041600097, . ] to own topic [my-topic] 2 3 Because of: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Dont eliminate PropertyFilter that have id ‘myclassFilter' ; no FilterProvider set up (because of site strings: de- .sample .Skills [ "payload" ] ) 4 at com .fasterxml .jackson .databind .exc .InvalidDefinitionException .out of (InvalidDefinitionException .coffees : 77 ) 

Some of our Java Beans use ato manipulate the serialization and deserialization. This requires a propertyFilter to be configured on the ObjectMapper.
Spring for Apache Kafka made a change to the JsonSerializer , introducing an ObjectWriter . When the ObjectWriter instance is created, the ObjectMapper configuration is copied, not referenced. Our test case was re-configuring the ObjectMapper with the appropriate propertyFilter after the ObjectWriter instance was created. Hence, the ObjectWriter didn't know anything about the propertyFilter (since the configuration was already copied). After some refactoring, changing how we create and configure the JsonSerializer , our test cases were kissbrides.com MГЎs consejos green.
Running our build $ mvn clean verify finally resulted in a green build. Everything is working as it should. We pushed our changes to Bitbucket and everything built like a charm.

Instructions discovered updating Spring Kafka


Courses learned while in the Spring Footwear up-date


Spring and Spring Boot do a great job documenting their releases, their release notes are well maintained. That being said, upgrading was challenging, it took quite a while before everything was working again. A big part of that is on us, for not following best practices, guidelines, etc. A lot of this code was written when the team was just starting out with Spring and Spring Boot. Code evolves over time, without refactoring and applying those latest practices. Eventually that catches up with you, but we use this as a learning experience and improved things. Our test cases are now significantly better, and we'll keep a closer eye on them moving forward.