Using from Java DSL - 6.3

Talend ESB Mediation Developer Guide

EnrichVersion
6.3
EnrichProdName
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
task
Design and Development
EnrichPlatform
Talend ESB

The route below will read the file contents and validate them against a regular expression.

from("file://inbox")
  .validate(body(String.class).regex("^\\w{10}\\,\\d{2}\\,\\w{24}$"))
.to("bean:MyServiceBean.processLine");

Validate is not limited to the message body. You can also validate the message header.

from("file://inbox")
  .validate(header("bar").isGreaterThan(100))
.to("bean:MyServiceBean.processLine");

You can also use validate together with simple.

from("file://inbox")
  .validate(simple("${in.header.bar} == 100"))
.to("bean:MyServiceBean.processLine");