See https://github.com/spring-projects/spring-kafka/issues/1549
Several Spring projects (spring-jms, spring-amqp, spring-kafka, ...) have mechanisms for mapping a typeId token to/from a class name, allowing decoupling of concrete types between sender and receiver.
The issue (in spring-kafka) is asking for a scan that looks for classes with a typeId annotation and automatically populate the type mapper with the mappings.
Rather than a specific solution for spring-kafka, I think it would be better to provide a generic spring-messaging annotation e.g SpringJsonType and, perhaps, a utility method Map<String, Class<?>> findJsonTypeIds(String... packagesToScan).
The individual projects could then use this utility to set up their components to use this mapping.
If there is agreement that this would be useful, I can work on a PR.
Comment From: rstoyanchev
@garyrussell since you need the changes anyway, how about preparing a proposal? Having something concrete to look at should be very helpful. Hopefully it isn't too hard to move the PR, if needed, to a different project.
Comment From: garyrussell
@rstoyanchev Sure; will do.
Comment From: garyrussell
@rstoyanchev Proposal here: https://github.com/spring-projects/spring-kafka/pull/1562
Comment From: rstoyanchev
Team Decision: after a discussion we've decided this doesn't fit well in spring-messaging which supports the invocation of handler methods where target type information is already available. It could help spring-jms but having it there doesn't help Spring Kafka. So for the time being no good way to share a solution.