我想用Flink消费来自Kinesis的POJO 有没有关于如何正确发送和反序列化消息的标准?
由于
答案 0 :(得分:1)
我解决了它:
DataStream<SamplePojo> kinesis = see.addSource(new FlinkKinesisConsumer<>(
"my-stream",
new POJODeserializationSchema(),
kinesisConsumerConfig));
和
public class POJODeserializationSchema extends AbstractDeserializationSchema<SamplePojo> {
private ObjectMapper mapper;
@Override
public SamplePojo deserialize(byte[] message) throws IOException {
if (mapper == null) {
mapper = new ObjectMapper();
}
SamplePojo retVal = mapper.readValue(message, SamplePojo.class);
return retVal;
}
@Override
public boolean isEndOfStream(SamplePojo nextElement) {
return false;
}
}