Upgrading Spring season Investigation Rest wasn’t effortless, however, which had nothing regarding Springtime Studies Other individuals by itself

Upgrading Spring season Investigation Rest wasn’t effortless, however, which had nothing regarding Springtime Studies Other individuals by itself

That being said, may possibly not add up to even do that. I cannot query brand new builders why it was done this method, they aren’t right here anymore. This project’s facts can only just be told with regards to Git history.

Lessons discovered upgrading Springtime Analysis Other people

We suspect we’re playing with Spring season Investigation Others completely wrong, incorrectly combination WebMVC concepts. If we hadn’t done so right from the start, anything might have manage far easier.

Our company is today carried out with the Spring season Data Others migration. It is time to circulate to our next Spring component, Spring Kafka.

Springtime Kafka

Spring season Kafka, or in other words Spring to possess Apache Kafka , is a fantastic way to explore Kafka in your Springtime methods. It gives effortless-to-play with themes for sending messages and you may regular Spring season annotations for ingesting texts.

Configuring the users

step one [ERROR] coffee.lang.IllegalStateException: Did not stream ApplicationContext 2 step three Considering: org.springframework.kidney beans.factory.BeanCreationException: Error creating bean with identity 'consumerFactory' outlined in category road funding [ de / software / config / KafkaConsumerConfig . class ]: cuatro 5 Caused by: java . lang . NullPointerException six at java . foot / java . util . concurrent . ConcurrentHashMap . putVal ( ConcurrentHashMap . java: ten11 ) eight at java . base / java . util . concurrent . ConcurrentHashMap . init >( ConcurrentHashMap . java: 852 ) 8 at org . springframework . kafka . center . 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 texts having JsonFilter


1 [ERROR] org .apache .kafka mon .mistakes .SerializationException : Is 't serialize study [Feel [payload=MyClass(Id=201000000041600097, . ] to possess situation [my-topic] 2 3 As a result of: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Usually do not handle PropertyFilter that have id ‘myclassFilter' ; no FilterProvider designed (courtesy source strings: de- .try .Experiences [ "payload" ] ) 4 at com .fasterxml .jackson .databind .exc .InvalidDefinitionException .away 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 https://lovingwomen.org/es/mujeres-alemanas/. Everything is working as it should. We pushed our changes to Bitbucket and everything built like a charm.

Courses learned upgrading Springtime Kafka


Lessons discovered during Spring season Boot improve


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.

Commenta per primo

Lascia un commento

L'indirizzo email non sarà pubblicato.


*