Application A writes to a Kafka Topic below User object (json):
public class UserEvent {
private UUID id;
private Object payload; // contains User fields name etc.
}
Application B is trying to consume this User object (User.java resides in application B project) with below application.yml (multiple binders):
binders:
azureEventHub:
type: kafka
environment:
spring:
kafka:
bootstrap-servers: servicebus.windows.net:9093
consumer:
key-deserializer: org.springframework.kafka.support.serializer.ErrorHandlingDeserializer
value-deserializer: org.springframework.kafka.support.serializer.ErrorHandlingDeserializer
properties:
spring.deserializer.key.delegate.class: org.apache.kafka.common.serialization.StringDeserializer
spring.deserializer.value.delegate.class: org.springframework.kafka.support.serializer.JsonDeserializer
spring.json.trusted.packages: com.*
spring.json.value.default.type: com.applicationb.User
Below is how my Spring Cloud Stream Processor class looks:
@Bean
public Function<Message<User>, String> userProcessor()
{.. }
But instead of converting the Message payload to "User" class it keeps throwing the error with the
Parent class "UserEvent" not found.
org.springframework.kafka.listener.ListenerExecutionFailedException:
Listener failed; nested exception is org.springframework.kafka.support.serializer.DeserializationException:
failed to deserialize; nested exception is org.springframework.messaging.converter.MessageConversionException:
failed to resolve class name. Class not found [com.abcd.UserEvent];
nested exception is java.lang.ClassNotFoundException: com.abcd.UserEvent
Any ideas ?