【发布时间】:2022-01-13 15:04:17
【问题描述】:
我有两个服务eshop 和eshop-notification-service。服务 eshop 向 Kafka 发送消息:Notification(String message, LocalDateTime timestamp),eshop-notification-service 使用它。
由于某种原因,在消息反序列化过程中,来自生产者的包名(com.example.eshop.model.Notification)保存在消息头中,结果,消费者端的反序列化失败并出现错误:
Caused by: org.springframework.messaging.converter.MessageConversionException: failed to resolve class name. Class not found [com.example.eshop.model.Notification]; nested exception is java.lang.ClassNotFoundException: com.example.eshop.model.Notification
而消费者端正确的包路径是:com.example.eshopnotification
我该如何解决这个问题?为什么包会保存在邮件头中?
【问题讨论】: