TIBCO File Adapters are used to enable flow of information between files and TIBCO Enterprise Service Bus. File Adapters provide publication and subscription services which are used to get the data from the file or to write the data to the file respectively.
In this step by step tutorial on File Adapters, you will learn how you can use TIBCO File Adapter publication service to receive data from the text file and use it in the TIBCO designer process.
Step 1: Add File Adapter Configuration in the project
First we need to add File Adapter configuration in the project. Go to File Adapter Palette and drop the File Adapter Configuration in your project as shown in below screenshot:
We don’t need to make any configuration changes for File Adapter Configuration.
Step 2: Add Publication Service in File Adapter and Configure it
Double Click on the File Adapter configuration that you added in Step 1. Go to Adapter Services folder and add a new publication service from the File Adapter Palette.
In the configuration tab of Publication service, we are choosing Rendezvous as transport. As we want adapter service to get triggered for every new record in the file, we choose Record Transfer in the Transfer mode. In the Life Cycle, choose repeating as we don’t want the adapter to get triggered only once.
I have chosen Polling Interval to 30 seconds in this example scenario. Choose Input Directory by using browse option. This input directory will contain the file for which we are configuring publication service.
As we want to use File Adapter service for a specific file only, in Recognition Method choose By File Name.
File Name field will contain the name of the file that we want to use as input for adapter service.
Configuration tab of the File Adapter Publication Service will look like below screenshot:
In the Processing tab, browse and specify the Working Directory. In the Post Processing option, choose Leave as is as we don’t want to move the file to any other directory after processing.
Below screenshot shows how I have configured Processing tab:
Now moving on to the next tab—Schema, we need to first create a schema and only then we can add that schema to this tab.
We need to have a Read Schema in our adapter’s File Schemas folder. Go to File Schemas folder and add a new Read Schema.
Double Click on this Read Schema and then add a new Delimited File Record by following the way as shown in the below screenshot:
I have named this record as Student. In the Configuration of this File Record, choose a delimiter. I am going to use comma (,) as a delimiter in this example. In the Identifier Type, choose Field Value.
In the Attributes, we add record attributes by clicking on Add button. In this example, I have given the following attributes which will be used when adding content to the file:
Now that we have created the Read Schema and configured its record, we can move back to the Schema tab of our File Adapter Publication service.
In the Schema tab, add the Student Schema. It will now look like below:
In the Transport tab, we will have to specify the RV Subject, Quality of Service and Wire Format as shown below:
With this, we are done with the configuration and setup of our File Adapter Publication Service.
Step 3: Create a TIBCO Process with Adapter Subscriber to Receive data from File Adapter Publication Service
In this step, we will create a TIBCO Designer Process that will be able to receive the data from the file adapter publication service and will make the data available to the process. In real scenarios, data needs to be used in some way in the process after receiving it through Adapter Subscriber but in this example case, we will just receive the data and end the process.
Create a new process and add Adapter Subscriber Activity. As this activity is a process starter, it will replace the default Start activity from the process.
In the Configuration tab of the Adapter Subscriber, choose the File Adapter Publication Service that we created in previous step. This is shown in the diagram below:
In the Transport tab, we need to ensure that all our transport configurations including the Subject are matching with the Transport configuration of our Adapter Publication Service (which was configured in Step 2).
In below screenshot you can see the Transport parameters that I have used for Adapter Subscriber activity in this example:
We don’t need to make any further changes in the process. We are now ready to process with the testing step.
Step 4: Test File Adapter Publication Service
For testing the adapter based applications like this, we need to run two testers. First we need to run Adapter Tester and then designer tester.
Go to tools and click on Show Adapter Tester. A new window will open in which you have to select the file adapter and also specify a working directory as shown below:
Now click on the Start button which will start the adapter service. Now load the process that you created in previous step in the Designer Tester.
Once our adapter service and our process are ready in their respective testers, we can move forward and try adding a new record in the file.
Go to the file in the Input direcotory (in our example case the file is information.txt).
Add the following new record in the file and save:
As you can see in the below screenshot, information has been pulled in by the adapter service and has been received by the Adapter Subscriber in the process: