You are viewing an older version of this section. Click here to navigate to the latest version.

Filtering Invalid Requests

Sometimes you need to prevent your Mule application from processing requests known to be invalid or that have invalid data. This example shows you how to use filters to reject such invalid requests.

What You Will Learn

  • How to use filters to control which requests are processed

  • How to configure a particular kind of filter, the "Wildcard" filter

    Watch a video

    See this example built and run in Mule Studio

Build It Now! (10 minutes)


This example adds a new filter to the existing 'core-concepts' project created in the Adding Business Logic to a Flow example.

Building the Example

  1. Make sure the "Message Flow" view is open in Mule Studio:


  2. Select the "Filters" panel and drag the "Wildcard" filter, dropping it on top of the arrow leaving the HTTP inbound end-point:


  3. Double click the Wildcard filter you just added and enter "/Mule-" in the pattern field and "Mule- Filter" in the name field. Be sure to check the "Case Sensitive" check box:


  4. Click the Documentation tab and fill in the description field:


Running the Example

To run the example, right click in the project tree, select Run As.. -→ Mule Application. You’ll see logging information in the console window as the application starts.

In a browser window go to http://localhost:8082/Fred and you should see the following on screen:


The application quite rudely refused to greet Fred. Now go to go to http://localhost:8082/Mule-Fred instead. You should see the following:


Notice that the application now has a Mule bias.

What Just Happened?

  • You added a filter to a flow. The filter conditionally controls which data is allowed to pass through to the flow

  • You modified an HTTP inbound end-point to reject requests that do not start with "Mule-". Rejected requests are not passed on.