Upgrading Spring Research Rest was not easy, however, that had nothing regarding Spring Analysis Other individuals alone

Having said that, may possibly not add up to even do this. I can not ask the new designers as to why it had been done so way, they’re not right here any more. This project’s facts can only just find out through its Git record.

Classes discovered upgrading Spring season Analysis Other individuals

I think the audience is playing with Springtime Research Other individuals incorrect, incorrectly blend WebMVC maxims. Whenever we had not done so right away, some thing would have manage much simpler.

We’re now completed with this new Springtime Studies Other people migration. It is time to circulate onto the 2nd Springtime module, Spring Kafka.

Springtime Kafka

Springtime Kafka, or rather Spring season for Apache Kafka , is a great treatment for explore Kafka on your Spring tactics. It offers easy-to-use layouts to possess sending texts and you will regular Springtime annotations to have consuming messages.

Configuring new customers

1 [ERROR] coffee.lang.IllegalStateException: Failed to load ApplicationContext 2 step three Brought about by: org.springframework.kidney beans.warehouse.BeanCreationException: Error creating bean having name 'consumerFactory' defined in classification roadway investment [ de / application / config / KafkaConsumerConfig . class ]: cuatro 5 Caused by: java . lang . NullPointerException 6 at java . legs / java . util . concurrent . ConcurrentHashMap . putVal ( ConcurrentHashMap . java: ten11 ) 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 texts which have JsonFilter


1 [ERROR] org .apache .kafka mon .errors .SerializationException : Can also be 't serialize data [Enjoy [payload=MyClass(Id=201000000041600097, . ] for issue [my-topic] 2 3 For the reason that: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Never resolve PropertyFilter that have id ‘myclassFilter' ; no FilterProvider configured (as a result of resource strings: de .decide to try .Experience [ "payload" ] ) 4 during the 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 green.
Running our build $ mvn clean verify finally resulted in a green Correo electrГіnico de verificaciГіn de rubrides build. Everything is working as it should. We pushed our changes to Bitbucket and everything built like a charm.

Instructions read updating Spring season Kafka


Coaching discovered during the Spring season Boot inform


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.

Leave a Comment