Skip to main content Skip to complementary content

Configuring the components and connections

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.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!