How can the pre-processing feature of FA be used to Add header/info in each message by using a script?

How can the pre-processing feature of FA be used to Add header/info in each message by using a script?

book

Article ID: KB0087643

calendar_today

Updated On:

Products Versions
TIBCO ActiveMatrix BusinessWorks Plug-in for Files for Unix and Windows -
Not Applicable -

Description

Description:
If you want to publish a messages using an FA publisher, and

1). Your input file has header/info in the beginning of the file.
2). There are multiple messages having only data.
3). You want to publish each message with header/info along with the data in the message.

You can write a script which will insert the header for the remaining data in the file.

Example. If sample input file content is as follows:

1(header)
5(info)
6 (first #6)
7 (first #7)
6 (second #6)
7 (second #7)
6 (third #6)
6(fourth #6)
7 (third #7)
8 rows

Requirement: Need to modify the input file content in such a way that you always publish 1,5,6,7, so your processed file should look like the following:

1
5
6 (first one)
7 (first #7)
1(ADDED BY OUR PRE PROCESSING SCRIPT)
5(ADDED BY OUR PRE PROCESSING SCRIPT)
6 (second #6)
7 (second #7)
1(ADDED BY OUR PRE PROCESSING SCRIPT)
5(ADDED BY OUR PRE PROCESSING SCRIPT)
6 (third #6)
1(ADDED BY OUR PRE PROCESSING SCRIPT)
5(ADDED BY OUR PRE PROCESSING SCRIPT)
6(fourth #6)
7 (third #7)

Note: 8 row (deleted BY OUR PRE PROCESSING SCRIPT).

Issue/Introduction

How can the pre-processing feature of FA be used to Add header/info in each message by using a script?

Resolution

Resolution:
===========
The script will need to parse and modify the original input file and properly insert 1, 5, or both in front of 5 and 6 wherever needed. Regarding the schema, the records will be positional and be identified by keyword which is the first letter (1/5/6/7).

Implementation Details:

Create sample project (Design) with publication service having positional delimiter schema.

Read the Schema (positional) structure:

Header (to parse line starting with 1).
Info (to parse line starting with 5).
Data (to parse line starting with 6).
Optional Data (to parse line starting with 7).

Create a sample Java program (ReplaceFileContents.java) to modify the input file data. (You can implement the same logic in your favorite programming language/scripting language if needed.)

Create a preprocessing script to call the sample Java program.

Configure all directories as per your environment.
 
Place ReplaceFileContents.java and the ReplaceFileContents.class file into your temp directory. (Working directory of Designer tester.)

Run the project.

Attachments:
===========
Filename: Design.zip (sample project with preprocessing script and Java code.)

Attachments

How can the pre-processing feature of FA be used to Add header/info in each message by using a script? get_app