33 lines
961 B
Java
33 lines
961 B
Java
package com.baeldung.flink.schema;
|
|
|
|
import com.baeldung.flink.model.InputMessage;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
|
import org.apache.flink.api.common.serialization.DeserializationSchema;
|
|
import org.apache.flink.api.common.typeinfo.TypeInformation;
|
|
|
|
import java.io.IOException;
|
|
|
|
public class InputMessageDeserializationSchema implements
|
|
DeserializationSchema<InputMessage> {
|
|
|
|
static ObjectMapper objectMapper = new ObjectMapper().registerModule(new JavaTimeModule());
|
|
|
|
|
|
@Override
|
|
public InputMessage deserialize(byte[] bytes) throws IOException {
|
|
|
|
return objectMapper.readValue(bytes, InputMessage.class);
|
|
}
|
|
|
|
@Override
|
|
public boolean isEndOfStream(InputMessage inputMessage) {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public TypeInformation<InputMessage> getProducedType() {
|
|
return TypeInformation.of(InputMessage.class);
|
|
}
|
|
}
|