Configuring the components and connections - 6.4

Logs and errors - Mediation

author
Talend Documentation Team
EnrichVersion
6.4
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
Data Governance > Third-party systems > Logs and errors components (Mediation)
Data Quality and Preparation > Third-party systems > Logs and errors components (Mediation)
Design and Development > Third-party systems > Logs and errors components (Mediation)
EnrichPlatform
Talend Studio

Procedure

  1. Double-click the cFile component labeled Sender to open its Basic settings view in the Component tab.
  2. In the Path field, fill in or browse to the path to the folder that holds the source files.
  3. From the Encoding list, select the encoding type of your source files. Leave the other parameters as they are.
  4. Repeat these step to define the output file path and encoding type in the Basic settings view of the other cFile component, which is labeled Receiver.
  5. Double-click the cProcessor component labeled Throw_exception to open its Basic settings view in the Component tab, and customize the code in the Code area to throw an exception and display relevant information if any file coming via the try connection does not meet the content requirement, as follows:
    String body = exchange.getIn().getBody(String.class);
    System.out.println("\nTrying: "+body);
    Exception e = new Exception("Only 'Talend Integration Solutions' is acceptable. Please check the file:");
    if(!"Talend Integration Solutions".equals(body)){
    	throw e;
    }else{
        System.out.println("File is good.");
    }
  6. Click the catch connection and then the Component tab to open its Basic settings view, and fill the Expression field with an expression to specify the type of exception to catch.
    In this scenario, fill in Exception.class to catch any exception thrown.
  7. Double-click cProcessor component labeled Show_exception to open its Basic settings view in the Component tab, and customize the code in the Code area to display the exception information and the related file name, as follows:
    System.out.println(exchange.getProperty("CamelExceptionCaught")+
    " " + exchange.getIn().getHeader("CamelFileName"));
  8. Click Ctrl+S to save your Route.