I had read in a Flume book that if in the intercept method of interceptor an event is returned as null, the event will be dropped. Hence i have created a custom interceptor which on basis of a condition returns the event as null like:
public Event intercept(Event event) {
// TODO Auto-generated method stub
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) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finalEvent = null;
}
System.out.println("Event is : " + finalEvent);
return finalEvent;
}
The interceptor emits null event but the file channel still passes it to the HDFS sink as empty. Why doesn't the event get dropped?? I am using Spooling directory as source.