Cannot catch exception throws by kafka consumer with JSONKeyValueDeserializationSchema

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Cannot catch exception throws by kafka consumer with JSONKeyValueDeserializationSchema

Zhechao Ma
Hello,

I'm using flinkKafkaConsumer to read message from a kafka topic with JSONKeyValueDeserializationSchema. When the message is json formatted, everything works fine, but it throws NullPointerException when processing a message is not json formatted. I try to catch the exception but cannot do that.

Can anyone give out some tips?

flink: 1.5
flink-kafka: 1.5
kafka-clients: 0.10.1.2_2.11
flink-json:

--
Thanks
Zhechao Ma
Reply | Threaded
Open this post in threaded view
|

Re:Cannot catch exception throws by kafka consumer with JSONKeyValueDeserializationSchema

Haibo Sun
Hi,   Zhechao 

Usually, if you can, share your full exception stack and where you are trying to capture exceptions in your code (preferably with posting your relevant code directly
). That will help us understand and locate the issue you encounter.

Best,
Haibo

At 2019-07-08 14:11:22, "Zhechao Ma" <[hidden email]> wrote:
Hello,

I'm using flinkKafkaConsumer to read message from a kafka topic with JSONKeyValueDeserializationSchema. When the message is json formatted, everything works fine, but it throws NullPointerException when processing a message is not json formatted. I try to catch the exception but cannot do that.

Can anyone give out some tips?

flink: 1.5
flink-kafka: 1.5
kafka-clients: 0.10.1.2_2.11
flink-json:

--
Thanks
Zhechao Ma
Reply | Threaded
Open this post in threaded view
|

Re: Cannot catch exception throws by kafka consumer with JSONKeyValueDeserializationSchema

Zhechao Ma
I'm trying to catch exception throws by the kafka source, and I've got the answer that exception in source or  sink cannot be caught.

Thanks

Haibo Sun <[hidden email]> 于2019年7月8日周一 下午3:54写道:
Hi,   Zhechao 

Usually, if you can, share your full exception stack and where you are trying to capture exceptions in your code (preferably with posting your relevant code directly
). That will help us understand and locate the issue you encounter.

Best,
Haibo

At 2019-07-08 14:11:22, "Zhechao Ma" <[hidden email]> wrote:
Hello,

I'm using flinkKafkaConsumer to read message from a kafka topic with JSONKeyValueDeserializationSchema. When the message is json formatted, everything works fine, but it throws NullPointerException when processing a message is not json formatted. I try to catch the exception but cannot do that.

Can anyone give out some tips?

flink: 1.5
flink-kafka: 1.5
kafka-clients: 0.10.1.2_2.11
flink-json:

--
Thanks
Zhechao Ma


--
Thanks
Zhechao Ma
Reply | Threaded
Open this post in threaded view
|

Re: Cannot catch exception throws by kafka consumer with JSONKeyValueDeserializationSchema

Fabian Hueske-2
Hi,

I'd suggest to implement your own custom deserialization schema for example by extending JSONKeyValueDeserializationSchema.
Then you can implement whatever logic you need to handle incorrectly formatted messages.

Best, Fabian

Am Mi., 10. Juli 2019 um 04:29 Uhr schrieb Zhechao Ma <[hidden email]>:
I'm trying to catch exception throws by the kafka source, and I've got the answer that exception in source or  sink cannot be caught.

Thanks

Haibo Sun <[hidden email]> 于2019年7月8日周一 下午3:54写道:
Hi,   Zhechao 

Usually, if you can, share your full exception stack and where you are trying to capture exceptions in your code (preferably with posting your relevant code directly
). That will help us understand and locate the issue you encounter.

Best,
Haibo

At 2019-07-08 14:11:22, "Zhechao Ma" <[hidden email]> wrote:
Hello,

I'm using flinkKafkaConsumer to read message from a kafka topic with JSONKeyValueDeserializationSchema. When the message is json formatted, everything works fine, but it throws NullPointerException when processing a message is not json formatted. I try to catch the exception but cannot do that.

Can anyone give out some tips?

flink: 1.5
flink-kafka: 1.5
kafka-clients: 0.10.1.2_2.11
flink-json:

--
Thanks
Zhechao Ma


--
Thanks
Zhechao Ma