Click here to Skip to main content
15,915,818 members
Articles / Programming Languages / ECMAScript / ESB
Tip/Trick

Mule ESB: Creating Custom Fliter

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
29 Aug 2016CPOL 6.5K  
Mule ESB: Creating Custom Fliter

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.

Java
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 Payload is a Stream or not*/
        return obj instanceof java.io.InputStream;
    }
}

Provide this class in Custom Filter component from the palette.

Your custom filter is now ready to use!

XML
<custom-filter class="org.rahul.mule.filter.InputStreamFilter" doc:name="Streamable Filter">
      </custom-filter>

I hope this helps!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --