news

Upgrading Spring season Data Other people wasn’t easy, however, that had absolutely nothing regarding Spring Research Others in itself

Datum: 2024-03-19 Verleger: 紫鸽电气 Durchsuche: 67

Upgrading Spring season Data Other people wasn’t easy, however, that had absolutely nothing regarding Spring Research Others in itself

That being said, it might not make sense to even do that. I can not inquire new designers why it absolutely was done this means, they’re not here any longer. So it project’s facts are only able to find out employing Git records.

Instruction read updating Spring Research Rest

We think we have been playing with Springtime Investigation Other people completely wrong, wrongly mix WebMVC rules. If we had not done so right from the start, one thing might have manage much much easier.

We are now completed with the Springtime Studies Others migration. It is time to disperse on to our very own second Springtime module, Spring season Kafka.

Spring season Kafka

Spring Kafka, or in other words Spring season to have Apache Kafka , is an excellent cure for play with Kafka on your Spring season projects. It gives simple-to-use templates to possess delivering texts and you will regular Springtime annotations to have sipping messages.

Configuring new customers

step step 1 [ERROR] coffees.lang.IllegalStateException: Didn't weight ApplicationContext 2 3 Considering: org.springframework.kidney beans.facility.BeanCreationException: Mistake performing bean with name 'consumerFactory' laid out in group road funding [ de / application / config / KafkaConsumerConfig . class ]: 4 5 Caused by: java . lang . NullPointerException 6 at java . legs / java . util . concurrent . ConcurrentHashMap . putVal ( ConcurrentHashMap . java: 1011 ) seven at java . swoonbrides.net buen sitio 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 messages having JsonFilter


1 [ERROR] org .apache .kafka mon .problems .SerializationException : Can also be 't serialize analysis [Skills [payload=MyClass(Id=201000000041600097, . ] to own matter [my-topic] 2 3 Because of: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Do not take care of PropertyFilter having id ‘myclassFilter' ; no FilterProvider set up (thanks to reference strings: de- .test .Experiences [ "payload" ] ) 4 within com .fasterxml .jackson .databind .exc .InvalidDefinitionException .away from (InvalidDefinitionException .java : 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.

Lessons discovered updating Spring season Kafka


Coaching discovered throughout Springtime Footwear enhance


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.
  • Bisherige: first page...
  • Nächster: last page...
  • 网站流量监控代码