This article adds a file poller process with Render XML activity and sets up a few global variables for configurations. At the end of this article, we will have something like this.
For now, the following are configurable:
- Inbound directory: DirInboundFolder (default to ‘c:\fgw\inbound\’)
- Outbound directory: DirOutboundFolder (default to ‘c:\fgw\outbound\’)
- Semaphore file extension: InboundSemaphoreExt (default to ‘done’)
- Semaphore extension separator: InboundSemaphoreExtSeparator (default to ‘.’)
- Search pattern: InboundSemaphorePattern (default to ‘*’)
This article assumes that you already knew how to perform basic tasks in TIBCO Designer.
1) Add a new folder under the FileGateway root folder.
2) Add a new process definition with a name PollEmpsCSV
3) Double-click the newly created process definition. Add a File Poller activity into the process. Note that the original ‘Start’ activity is now replaced by the File Poller activity.
4) Configure the File Poller activity.
In the Configuration tab, paste the following string into the File Name field:
%%DirInboundFolder%%%%InboundSemaphorePattern%%%%InboundSe
maphoreExtSeparator%%%%InboundSemaphoreExt%%
The global variable name surrounded by double % signs will be resolved during run time.
In the Advanced tab:
5) Expand the ParseAndTransform folder in the Project Panel. Drag the ‘ParseAndTransform’ process into the PollEmpsCSV process. Wire the PollDumpCompletion activity, ParseAndTransform process and the End activity in the following order.
6) An input parameter has already been defined earlier in the ‘Start’ activity of the ParseAndTransform process. This parameter holds the fully qualified name of the file to be parsed by the parser. While the Poller activity polls for the semaphore file, we will need to construct the filename required. This step assumes that the semaphore file without the extension is the filename to be processed.
In the input tab of ParseAndTransform sub-process, click on the pencil icon to bring up the XPath editor.
Paste the following XPath formula into the formula pane.
tib:substring-before-
last($PollDumpCompletion/ns:EventSourceOuputNoContentClass/fileInfo/fullName,string-
length($_globalVariables/pfx:GlobalVariables/InboundSemaphoreExtSeparator) + string-
length($_globalVariables/pfx:GlobalVariables/InboundSemaphoreExt))
The above XPath formula returns the filename required by the ParseEmpsCSV activity inside the sub-process. If the semaphore filename is
c:\fgw\inbound\emp001.txt.done
then the input filename to the parser activity will be
c:\fgw\inbound\emp001.txt
There are different ways to implement semaphore. Another alternative is to rename the source file when the transfer/file creation by the legacy system has completed. Semaphore is required when writing large file that takes time to complete. This is to avoid the process from reading an incomplete file.
7) The ParseAndTransform sub-process provides 2 output elements in its output schema defined in its ‘End’ activity. Refer step 13 of part 1 of this article.
Add a render XML activity followed by a write file activity. The write file activity will use the filename specified in the ‘outputFileName’ element of the ParseAndTransform output schema.
8) For the sake of simplicity, add a ‘Catch’ activity that catches all unhandled exceptions.
The final process looks like this.