Upgrading Spring season Data People wasn’t simple, however, which had nothing to do with Springtime Investigation Other people in itself

Upgrading Spring season Data People wasn’t simple, however, which had nothing to do with Springtime Investigation Other people in itself

That said, it might not sound right to do this. I can not query the newest designers as to the reasons it absolutely was done so method, they’re not right here more. Which project’s tale can only be told with regards to Git background.

Sessions learned upgrading Spring season Analysis Others

I suspect we are having fun with Spring Data Other individuals incorrect, improperly fusion WebMVC maxims. When we hadn’t done so from the beginning, things would have work with much convenient.

The audience is today finished with the fresh Spring Studies Others migration. It is the right time to flow onto all of our next Spring module, Spring Kafka.

Springtime Kafka

Springtime Kafka, or in a las mujeres Turco les gusta el pene grande other words Spring season to own Apache Kafka , is a great answer to use Kafka on the Spring strategies. It offers easy-to-explore templates to have giving texts and you may normal Spring season annotations to own sipping texts.

Configuring the fresh customers

step step 1 [ERROR] coffee.lang.IllegalStateException: Didn't load ApplicationContext 2 3 Due to: org.springframework.beans.warehouse.BeanCreationException: Error carrying out bean with identity 'consumerFactory' defined in group roadway resource [ de / software / config / KafkaConsumerConfig . class ]: cuatro 5 Caused by: java . lang . NullPointerException six at java . base / java . util . concurrent . ConcurrentHashMap . putVal ( ConcurrentHashMap . java: ten11 ) seven at java . base / java . util . concurrent . ConcurrentHashMap . init >( ConcurrentHashMap . java: 852 ) 8 at org . springframework . kafka . key . DefaultKafkaConsumerFactory . init >( DefaultKafkaConsumerFactory . java: 125 ) nine 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 having JsonFilter


1 [ERROR] org .apache .kafka mon .mistakes .SerializationException : Can 't serialize study [Experience [payload=MyClass(Id=201000000041600097, . ] having thing [my-topic] 2 3 Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Try not to care for PropertyFilter that have id ‘myclassFilter' ; zero FilterProvider set up (because of source chain: de .test .Enjoy [ "payload" ] ) 4 during the com .fasterxml .jackson .databind .exc .InvalidDefinitionException .from (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 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.

Courses discovered upgrading Spring season Kafka


Instructions read throughout Spring season Boot change


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.