Wednesday, December 18, 2013

By default when we poll the file using file adapter, it starts reading the file as soon as we deployed our composite to server. To get more control over it we can use trigger file option available in file adapter.

When we choose “Trigger File” checkbox, file adapter will not poll/read the file/files from specified directory unless it see trigger file in trigger file directory. Once trigger files is there in the trigger file directory, file adapter will start polling the files.

Suppose we have one business scenario, we should not poll/read the files which contain information regarding student unless source system writes all the files to required location. We will use trigger file option available to handle this scenario and polling will only start when source system writes all the files to specified location and put one trigger file to trigger file directory in the end.

To add File adapter to your composite, choose “File Adapter” from service adapters and drag it to the composite.

Choose “Read” operation as we will poll/read the file.



Specify polling file directory and check "Delete files after successful retrieval" if you want to delete the file after reading.
Set the polling frequency.


Check the “Trigger File” option. The trigger file directory can be the same as the inbound polling directory or different from the inbound polling directory. However, if your trigger file directory and the inbound polling directory are the same, then you should ensure that the name of the trigger file is not similar to the polling file.
If you want to use different directory for trigger file then don’t check the “Use directory for incoming files” checkbox and provide trigger directory and file name.




If you want to use same directory for trigger file then check “Use directory for incoming files” checkbox and provide trigger file name.
 
Browse required schema and choose schema element.
 
Testing Results:
Source system wrote Student.xml file to specified directory but polling didn’t start yet because trigger file is not there.
Once source system place trigger file to specified directory.
 
Once trigger file is placed in specified directory, file adapter will poll the Student.xml file and process it.



5 comments :

  1. Hi Vivek,

    Just wanted to ask you a small thing regarding trigger file scenario. Can we pass the Triggerfilename = "*.txt" or it is mandatory to give the specific filename as 'trigger.txt' always. I have to test a scenario where trigger file is written in the folder but it will be of the form 'trigger_20140910.txt' , so want to use wildcard chars.

    ReplyDelete
    Replies
    1. It is not mandatory to give 'trigger.txt' as trigger file name, you can give any name. You can try to use"*.txt" as trigger file name and check if that works or not.

      Delete
  2. No, vivek it's not working that way. That's why I wanted to check with you if you already tried this scenario of passing '*.txt'. Any other property you know using which we can pass the trigger filename like this?

    Regards,
    Vatan

    ReplyDelete
    Replies
    1. No Vatan, There is no other property to set trigger file name, however you can set trigger file directory at run time. Refer below link for more details.

      http://docs.oracle.com/cd/E15523_01/integration.1111/e10231/adptr_file.htm#CACJJIBC

      Vivek

      Delete
    2. Ok vivek, thanks for your input !

      Regards,
      Vatan

      Delete