Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spring.json.type.mapping, kafka producer doesn't work with spring boot 3.3.0 #41240

Open
SzestKam opened this issue Jun 26, 2024 · 3 comments
Open
Labels
status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged

Comments

@SzestKam
Copy link

I have problem after upgrade spring boot version from 3.2.6 to version 3.3.0

other dependency, they're the same even I change spring boot version:
org.springframework.kafka:spring-kafka:3.2.0
com.fasterxml.jackson.module:jackson-module-kotlin:2.17.1
io.projectreactor.kafka:reactor-kafka:1.3.23

configuration for spring kafka

spring:
  kafka:
    bootstrap-servers:
      - localhost:9092
    producer:
      key-serializer: org.apache.kafka.common.serialization.StringSerializer
      value-serializer: com.charger.communication.service.config.CustomKafkaJsonValueSerializer
      properties:
        spring.json.type.mapping: "rawLogEvent:com.charger.communication.service.event.RawLogEvent,
        detailedLogEvent:com.charger.communication.service.event.DetailedLogEvent,"
    properties:
      spring.json.trusted.packages: "*"

in section above important mapping is: spring.json.type.mapping

CustomKafkaJsonValueSerializer is used to deliver customized com.fasterxml.jackson.databind.ObjectMapper

with sprig boot version 3.2.6 event on the kafka topic has inside the header key: __TypeId__ with value rawLogEvent so it means that mapping works as expected

with version 3.3.0 this key: __TypeId__ cointains entry com.charger.communication.service.event.RawLogEvent, no mapping applied

I tried to check documentation for each module, nowhere info about changes. Also I try to obey suggested configuration without expected results.

I need your help to understand how to properly use mappings with newer spring boot version.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 26, 2024
@SzestKam SzestKam changed the title spring.json.type.mapping, kafka producer doen't work with spring boot 3.3.0 spring.json.type.mapping, kafka producer doesn't work with spring boot 3.3.0 Jun 26, 2024
@wilkinsona
Copy link
Member

other dependency, they're the same even I change spring boot version

Upgrading from Spring Boot 3.2.x to Spring Boot 3.3.x should also upgrade Spring Kafka from 3.1.x to 3.2.x. Are you saying that you've overridden (or are not using) Spring Boot's dependency management? While it may not resolve this problem, you shouldn avoid downgrading a dependency to an older minor version as compatibility is not guaranteed.

spring.json.type.mapping

This is a Spring Kafka property. It's not clear to me from what you've described if Spring Boot is not passing it correctly into Spring Kafka or if Spring Kafka is not picking it up as it should.

If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Jun 26, 2024
@SzestKam
Copy link
Author

We don't use Spring Boot's dependency management in the project.

I put the question here because the issue is visible only when I change the Spring Boot version to higher. For some reason, Spring Kafka has been distributed with the newest version of the Spring Boot.

If it's necessary I'll try to prepare examples from my code.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jun 27, 2024
@wilkinsona
Copy link
Member

If it's necessary I'll try to prepare examples from my code.

Yes please. There are too many unknowns at the moment with only a handful of properties to go on.

@wilkinsona wilkinsona added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

3 participants