Warning: A non-numeric value encountered in /home/customer/www/archive.ricston.com/public_html/wp-content/themes/Divi/functions.php on line 5766

In a previous post we have seen how to create a simple chat application using Mule. We are now going to extend this application to enable message filtering.

As it is, the application allows anyone to say whatever they want on the chat and this might include offensive language. So the next feature we would like to add is to filter out messages that contain offensive language.

We can achieve this by using a wildcard filter. Of course, a more advanced filter could be implemented if you want, which could be backed by a database or web service for example.
But in our case we are using the following filter:


    

In this example we filter out messages that contain two specific words (of course in the ‘real’ filter we would need to use the actual words but you probably can guess what they are).

What we would like as well is that instead of simply dropping the offensive messages, we want to store them in a specific file and to send an email to the administrators to warn them of such behaviour. This is easily done using the message-filter since it allows us to decide if we want to throw an exception when a message is unaccepted and to also specify a particular message flow. So for this we can use the following element that uses the rudeWordsFlow when the message is not accepted…


        
        
            
                
            
        
        
...

The rudeWordsFlow is quite a simple flow:


    
    
        
    
    
        
        
    

This brings us to the end of this very simple example. I hope that this is useful to at least some of you Mule ‘newbies’ out there…