I read in the Flume book that if the event returns null in the interceptor method, the event will be deleted. Therefore, I created a special interceptor that, based on the condition, returns the event as null, for example:
public Event intercept(Event event) {
Event finalEvent = event;
check = new String(event.getBody(),Charsets.UTF_8);
if(check.matches("([0-9]-.+?-.+?-[0-9][0-9]+)")){
try {
fileWriter.append(new String(event.getBody(),Charsets.UTF_8)+ "\n");
} catch (IOException e) {
e.printStackTrace();
}
finalEvent = null;
}
System.out.println("Event is : " + finalEvent);
return finalEvent;
}
The interceptor emits a null event, but the file channel still passes it to the HDFS receiver as empty. Why doesnβt the event drop out? I use the Spooling directory as a source.
source
share