Site icon techieswiki

TIBCO BusinessWorks Tutorial: How to Read Data from a File line by line and send to queue

In this step by step TIBCO Tutorial, I will read data from a text file (inputData.txt). The data in the text file will be a pipe (|) separated and It will have Name, Email, and Phone.

Once data is read from the queue, we need to send each row as separate messages to the queue.

Step 1: Create JMS Connection

As we are going to send the data to the EMS queue, we need to create a Connection to the EMS server. JMS Connection activity and configure it as shown in below screenshot. I am using the EMS as localhost. Using Test Connection make sure the configuration is correct and able to connect to the EMS server.

Step 2: Data Format

We need this Data Format pallet to parse the data details from the input file. This shared configuration resource specifies the type of formatting for the text (delimited columns or fixed-width columns), the column separator for delimited columns, the line separator, and the fill character and field offsets for fixed-width columns. You must also specify the data schema to use for parsing or rendering the text. Add this pallet to your project and configure it in as shown below.

Step 3: Create Schema for the JMS Queue Sender

We need this schema created to send the data to the queue in XML Format. I have created the below schema for this.


Step 4: Create Process to Read Text File, Parse Contents and Send to QUEUE

This is our final step in our goal. We need to add all the logic to this session. The complete process will look like below.

Let’s discuss each activity in detail.

  1. Timer ActivityThis activity can be used to schedule the job for a particular time or to run at particular intervals. Here I used this pallet to run my activity Every day at 7:00 PM.
  2. Read File ActivityRead File activity is used to read the source text file. Our source file for this example scenario is having content as below:
    Name|Email|Phone
    User1|user1@mail.com|123456778
    User2|user2@mail.com|123456779
    User2|user2@mail.com|123456779

    I have configured this activity as shown below.


  3. Parse DataIn this activity configuration tab we need to select the Data Format which we created in Step 2. I have checked the “Manually Specify Start Record:” checkbox as I don’t want to pass the header (first line). For NoOfRecords field, we specify -1 as we want to read all the records from the source text file.
    5. Group ActivityAs we want to send all the records parsed to an EMS Queue, we need to use Iterate group and enclose JMS Queue Sender activity in the group. For Iterate Group, we specify Group Action as Iterate and Output of Parse Data as Variable List as you can see in below diagram:
    6. JMS Queue Sender

    In the Configuration tab of JMS Queue Sender activity, we choose the Connection that was created in Step 1 and in the Input Editor tab, we need to choose the Schema which we created in Step 3 [Please note that the Input Editor tab will be active only if we select Message Type as XML Text in the configuration tab].

    Note: The above code will work for the small files but if you try to process a large file with this code you may get OutOfMemory error depends on your system memory and heap size setting. Read How To Process Large files in TIBCO BW to know more.

    That’s all folks. We have complete our project. Now you can run the test from the tester activity. Please make sure you selected Run Once while testing it if the Clock is not around 7 PM :).

    Hope the tutorial helps. Let me know your suggestions if you have any.

Exit mobile version