Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apache flink - the correct way of error handling

Tags:

apache-flink

I wonder if there is an option of built in error handling in Flink. there may be 2 cases:

  1. the current message from Kafka (in my case) is invalid, continue to next one

  2. uncaught exception - from what I saw it can stop the stream aggregation completely.

ho can I handle these 2 cases? (java code)

like image 951
Lior Goldemberg Avatar asked Oct 03 '16 12:10

Lior Goldemberg


People also ask

What are two forms of error handling?

Essentially, there are two types of errors: terminating and non-terminating.

What are error handling routines?

Error handling refers to the routines in a program that respond to abnormal input or conditions. The quality of such routines is based on the clarity of the error messages and the options given to users for resolving the problem.

How does Apache Flink work?

Flink is designed to run stateful streaming applications at any scale. Applications are parallelized into possibly thousands of tasks that are distributed and concurrently executed in a cluster. Therefore, an application can leverage virtually unlimited amounts of CPUs, main memory, disk and network IO.


1 Answers

1) This is done idiomatically with a flatMap: if your message is valid, you go on with a list containing your valid element (maybe already processed in the same step). If it's not valid, you simply return an empty list so that no elements are produced by that step. I could provide Scala code but I'm not familiar with Java APIs so I don't want to put you off track. Just check the flatMap call.

2) This depends on the type of exception: if it's provoked by your own code, just catch it and handle it inside the operator, or simply log it and move on. Without any further information about a specific case, this is the best I know of, but again, coming from Scala I haven't experienced runtime exceptions.

like image 73
Chobeat Avatar answered Dec 30 '22 05:12

Chobeat