问题描述
Producer发送JSON类型数据到Pular集群, Consumer在消费拿到数据时, 存在字段丢失现象. 具体类定义: 自定义三个类MessageBody, User, Student. MessageBody作为Schema.Type, User是MessageBody其中一个字段, Student是User的子类. 构建MessageBody时, User字段赋值为一个Student实例. 最终消息收到后, 反序列化回来, Student中的字段丢失了
public class RequestBody {
private String from;
private User user;
}
public class User {
private String ID;
private String name;
private Integer age;
}
public class Employee extends User {
private String title;
}
// 发送数据构建
RequestBody body = new RequestBody();
Employee employee = new Employee("001", "Xuwei", 33);
employee.setTitle("Software Engineer");
body.setFrom("test");
body.setUser(employee);
sendMessage(commonConfig.getTestTopic(), body);
// Consumer收到的数据
{
"from": "test",
"user": {
"name": "Xuwei",
"age": 33,
"id": "001"
}
}