Search
Calendar
April 2024
S M T W T F S
« Sep    
 123456
78910111213
14151617181920
21222324252627
282930  
Your widget title
Archives

PostHeaderIcon Filter too large files in Mule ESB

Case

You use a filter connector in Mule ESB 2.2.1, to perform any operation (let’s say: to send them on JMS, but this does not matter). You would like to filter files owing to their size, ie stop the handling of files larger than 10,000,000 bytes for instance.

We assume the files you handle are text files (not binary).

Solution

In your Mule XML config file, add the following block, using a short Groovy script:

<message-properties-transformer name="add-properties">
     <add-message-property key="fileSizeOK"
             value="#1" />
 </message-properties-transformer>

In the tag <file:inbound-endpoint>, add the attribute: transformer-refs="add-properties"
Now, add a tag <message-property-filter pattern="fileSizeOK=true"/>. Your outbound should then be similar to:

			<outbound>
                <filtering-router>
                    <jms:outbound-endpoint queue="lalou.jonathan.jms.queue"
						connector-ref="jmsConnector"/>
                    <message-property-filter pattern="fileSizeOK=true"/>
                </filtering-router>
                <forwarding-catch-all-strategy>
                    <file:outbound-endpoint path="/my/folder/"
                        connector-ref="fileConnector" outputPattern="error/#[header:originalFilename].too_big.#[function:dateStamp:yyyyMMdd_HHmmss_SSSSS].KO" />
                </forwarding-catch-all-strategy>
			</outbound>

Many thanks to Vincent N. for his help.

Leave a Reply