For incoming record I need to validate the value and based on result object I need to forward error to different topics and if successfully validated then forward the same using context.forward(). It can be done using DSL as provided in this link
using kafka-streams to conditionally sort a json input stream
I am not finding a clear way of doing this in processorAPI.
ValidateProcessor.java
@Override
public void process(String key, String value) {
Object result = //validation logic
if(result.isSuccessful()) {
context().forward(key, value);
}else {
context.forward("error",Object)
}
}
Now the caller again need to check and based on key need to differentiate the sink topic. I am using processorAPI because I need use headers.
Edit :
branch(new predicate{
business logic
if(condition)
return true
else
return false;
When the condition is false how to push to different stream. Currently creating another predicate which collects all other records which doesn't satisfy the above predicate in chain. Is there a way to do in same predicate?