Let's use the CSV File Reader adapter as an example. This is an adapter which reads a csv file as a resource.
By default, the Streaming runtime will look for resource files under the fragment project's src/main/resources/ folder. However, it may be required to load these files from different locations, depending on the environment in which the application is being deployed. In that case, you may use the epadmin 'deploydirectories' option, as noted in the
Help under Home > EP Commands > epadmin and epdev References > epadmin-node > (sub-heading) epadmin install node > (sub-heading) install Command Parameters.
First, create a Parameter in your EventFlow module to represent the CSV filename:
Here, we are setting the default value to 'file1.csv', which exists in the project's src/main/resources/ directory. This step is only needed so that the platform will successfully typecheck your application when working in Studio. This value will be overridden using a substitution variable later.
Next, set the CSV File Reader's 'File Name' property using the parameter ('csv_file') that you just created:
Next, create an EventFlow Deployment HOCON configuration to override the default value of the 'csv_file' parameter. Here, we use a substitution variable 'CSV_FILE':
EventFlowDeployment = { containers = { "A" = { moduleName = "com.tibco.sb.sample.adapter.csvreader.csvreader-sample.sbapp" containerParameterSettings = { parameters = { "csv_file" = "${CSV_FILE:-file1.csv}" } } } } }
Here, we're using the substitution variable 'CSV_FILE' to set the value for the 'csv_file' parameter. Again, a default value of 'file1.csv' is used to prevent any errors during Studio typecheck.
You may now run your EventFlow Fragment in Studio. In the Run Configuration under the 'Node' tab, specify the location to a different csv file. For example, C:/resources/:
Finally, assign a non-default value for the CSV_FILE substitution variable. Do this in your Run Configuration under the 'Parameters' tab:
This will ensure that 'file3.csv', located on the system under C:/resources/, will be loaded by the CSV File Reader. This is one example of how to configure projects to use external resource files.