In this tip, I will show you how to create a very simple Custom Filter inside your Mule flow.
At first, you need to create a Java class implementing the org.mule.api.routing.filter.Filter
, you have to override the accept()
method. Check out the below sample filter
which can be used to Filter out Input Streams java.io.InputStream
.
package org.rahul.mule.filter;
import org.mule.api.MuleMessage;
import org.mule.api.routing.filter.Filter;
public class InputStreamFilter implements Filter{
@Override
public boolean accept(MuleMessage message) {
Object obj = message.getPayload();
return obj instanceof java.io.InputStream;
}
}
Provide this class in Custom Filter component from the palette.
Your custom filter is now ready to use!
<custom-filter class="org.rahul.mule.filter.InputStreamFilter" doc:name="Streamable Filter">
</custom-filter>
I hope this helps!