1 Reply Latest reply on Apr 15, 2016 1:03 AM by Tomohisa igarashi

    Camel, rename file in case failure

    Paul Johansson Newbie

      Hi,

       

      I use camel routes for implementation of integration platform. My routes are defined in java DSL camel component and i use file binding.

       

      I have the following case:

      1. Get the file from inbound directory.
      2. Process of the file fails.
      3. Rename file by using dynamically determined value.
      4. Finally move file from source to error directory.

       

      CamelRoute.java:

       

      onException(Throwable.class)

           .setHeader("PrefixFileName", "error")

           .setProperty("PrefixFileName", "error");

       

      from("switchyard://InboundService")

           .throwException(new Exception());

       

      Property used in file input binding:

       

      moveFailed=/error/$${headers.PrefixFileName}.txt

       

      After tests i noticed that the files was moved from source to the error directory properly, but error file name is incorrect. File with the following file name was created: '.txt'. It seems headers is empty so my question is how to use error file name composed by headers?

       

      Similar code developed in camel without switchyard works fine. So maybe some additional activities are required to transfer headers from camel context (message composers and context mappers are not executed after raise error by camel code).

       

       

      switchayrd: 2.0.1

      eap: 6.4

      apache camel: 2.15.1