Nav
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 the video

See this example built and run in Mule Studio

10 minutes

Prerequisites

This example adds a new filter to the existing 'core-concepts' project created in the Understanding the Mule Message 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. Be sure to check the "Case Sensitive" check box.

  4. Click the Documentation tab and fill in the name and description fields.

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.

The application quite rudely refused to greet Fred. Now go to go to http://localhost:8082/Mule-Fred instead.

Notice that the application now has a Mule bias.

Summary

  • 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 just parroted back on the HTTP response and are not passed on to the HelloComponent.

References

  • [MULE3EXAMPLES:Working with Components]