Service Virtualization

Expand all | Collapse all

Trigger VS when a File is created

Jump to Best Answer
  • 1.  Trigger VS when a File is created

    Posted 09-11-2018 01:55 PM

    Is there an OOB option to create a virtual service that tracks a folder and gets triggered if a new file is found or based on File Watcher Assertion.

    It can track the folder continuously or in batch mode.

     

    I can run a windows service to track a folder but looking for more native option.

     

    Any leads?



  • 2.  Re: Trigger VS when a File is created

    Posted 09-11-2018 02:19 PM

    Yes, this can be done by creating a custom but simple virtual service that continuously loop every X amount of time. The time can be set through a number of ways. One way is to add a Scripted step at the end of the model, where you can add a line of code such as: Thread.sleep(1000); // sleep for 1 sec

     

    So I would imagine your VSM should have at least 3 steps in it:

     

    Listen/Marker -> Custom Step to Monitor Folder -> Scripted Step to sleep

     

    Followed by the Scripted step to sleep, you should make it loop back to the beginning of the VSM (the "Listen"/"Marker" step).

     

    The "Custom Step to Monitor Folder" can also be a Scripted Step with some code to read files from a folder to determine if changes have been made. If a change has been made then do some action within the step or make it go to another step that does some action based on the change in the folder.



  • 3.  Re: Trigger VS when a File is created

    Posted 09-11-2018 02:23 PM

    what will VS listen to? in other words, how will the transition happen from  Listen/Marker  step to Custom Step to Monitor Folder step?



  • 4.  Re: Trigger VS when a File is created
    Best Answer

    Posted 09-11-2018 03:30 PM

    The Marker step tells the VSE run time that the workflow is a virtual service - the VSE container would move the workflow execution to the Custom Step to Monitor Folder step - where you need to have your custom logic as mentioned by Will_Truong above.

     

    So it would be the  Custom Step to Monitor Folder step which "Listen" for folder changes