- Points to note
- Configuration and Testing
- Interaction Configurations
- Is input Binary?
- Is Input Base64 Encoded?
- FileWriter Configuration
- Use file details from message headers
- Append timestamp?
- Append Counter?
- Output Mode
- File Encoding
- Monitoring Configuration
- Expert Properties
- Input and Output
- Testing the Interaction Configurations
- Interaction Configurations
- Functional Demonstration
The FileWriter component writes the received data from its input port to the specified output file. The received data can either be plain text or binary data.
File Writer is capable of handling:
- Text files
Text content from input message is written to the configured file in text format.
Binary content from the input message is written to the configured file in binary format.
Points to note
- The component runs on the Peer Server and therefore the file paths and directories mentioned in the CPS should be valid on the machine where the Peer Server is running. If the component fails over to another peer, ensure that the machine on which the secondary Peer Server is running does have the same path available.
- The received XML equivalent of the unstructured plain text needs to be transformed to its original format using the XML > Flat component.
- FileWriter closes the file and moves it to the target directory on receiving a message having property COMPLETE whose value is set to true. This is useful even when you use Append if Exists output mode for the FileWriter component and you would like to close the file on the occurrence of this event.
- The FileWriter component uses the JMS Header filename to get the file name from the input message.
Configuration and Testing
Business logic configuration details are configured in the second panel, Interaction Configurations. Figure 1 illustrates the panel with Expert Properties view enabled.
Figure 1: Interaction Configurations properties
Is input Binary?
Specifies whether the input received on the input port is binary.
- If enabled, it writes the data as bytes into the target file.
- If disabled, it writes text to the specified target file in an unstructured fashion.
Is Input Base64 Encoded?
Specifies if the input is base64 encoded. The component will decode the base64 input before further processing.
Click the FileWriter Configuration ellipses button to set these properties.
Figure 3: FileWriter configuration properties
Is Configured for Different Machine?
Specifies whether the Peer Server on which the component is to be launched and Fiorano Studio are running on the same machine or on different machines. This helps the component to determine the type of dialog to be shown while providing the paths of Source Directory, Working Directory, and Error Directory. When both the Peer Servers and the Fiorano Studio is running on the same machine, the paths to the above specified directories can be chosen from a file dialog with the directory structure of the current machine as shown in Figure 2. Otherwise, a text editor will be shown where the paths of Source/Working/Error directories need to be typed in as shown in Figure 3.
- Enabled if the Peer Server on which the component is to be launched and the Fiorano Studio are running on different machines.
- Disabled if the Peer Server and Fiorano Studio are on the same machine.
In disabled state, paths of directories can be chosen from the file dialog. When the property is enabled, the paths of directories should be manually specified in the Text Editor as shown in Figure 2 and Figure 3.
Figure 4: Choosing directory path using File Dialog
Figure 5: Specifying directory path using Text Editor
Compute Paths relative to Directory
The path of the directory relative to which the paths of Target Directory, Working Directory, and Error Directory are computed. By default, this points to the FIORANO_HOME directory. If the paths specified for Target/Working/Error Directories are not absolute, their paths are calculated relative to the directory specified here.
The name of the file to which the input data has to be written is specified here. If the file with this name does not exist, a new file is created.
The path of the directory where the target file (with the data received on the input port) is created. An absolute path of the target directory or a path relative to the directory specified in Compute Paths relative to Directory can be specified here. While specifying a directory as the Target Directory, make sure that you have permissions to create/modify files present in this directory.
If Is configured for different machine? is disabled, clicking the ellipses button will open a file dialog, , where the directory can be chosen from the file system. Otherwise the file path is written in the text editor.
The path of the directory which should hold the files during intermediate processing. Either an absolute path or a path relative to the directory specified in the Compute Paths relative to Directory can be provided.
If Is configured for different machine? is disabled, clicking the ellipses button will open a file dialog, as shown in Figure 2, where the directory can be chosen from the file system. Otherwise, a text editor pops up where the path of the directory needs to be typed in. Shown in Figure 3.
Path of the directory which should hold the files for which the processing has not been successful.
Use file details from message headers
Specify if the file details are to be taken from the header of the input message.
- If enabled, the name of the target file would be the value of the header property FileName present on the input message and the target directory would be the value of the header property directory.
- If disabled, the value specified for the CPS property Filename is used.
Specifies whether a timestamp is to be appended to the name of the target file.
Specify the format in which the timestamp is to be appended to the name of the target file. Figure 23 shows the descriptions for the symbols that could be used in the Timestamp format.
Figure 6: Symbols used in Timestamp format.
Example: If Test.txt is the filename to which the data is to be written, the target file created could be Test_02042008_183950765.txt when the default format (ddMMyyyy_HHmmssSSS) is used.
- If enabled, it appends a counter to the name of each file processed by the FileWriter in addition to the timestamp. The name of the file would look like <filename><time stamp><counter>. Appending counter to file names ensures that no two files created can have the same name.
- If disabled, no counter is appended to the target file processed by the component FileWriter.
Example: If Test.txt is the filename to which the data is to be written, the target file created could be Test_02042008_183950765_0.txt when AppendCounter? is enabled.
Specify the way in which the output is to be created with the received data. Figure 5 shows the output formatting modes.
Figure 7: Output Mode
New file for each message
This option tells the FileWriter to create a new file for each input message that has been processed. When this output mode is being used, timestamp and counter can be appended to the filename using the properties Appendtimestamp? and Appendcounter?. The Appendtimestamp? option will be visible only when this option is selected as the OutputMode.
Append and close on timeout
This output mode is used for appending the content of all messages received till timeout, to a single file. During this time interval, the file is present in the Working directory. When the timeout occurs, the file is closed and is moved to the Target directory. Selecting this option will show the property FileTimeout(min) which can be used to set the timeout. Another property 'FileTimeout' will be visible when this mode is chosen.
Append Line Separator
Enable to append the text data with a line separator.
File Timeout (min)
The time for which the component has to wait before closing and moving the file from the Working directory to the Target directory is specified using this property. This is visible only when 'Append and close on timeout' is selected.
Timeout after last message
Messages will be appended until timeout between two successive messages meets the timeout specified in the File TimeOut property.
Append and close on event
This output mode is used for appending the content of all received messages to a single file until CLOSE_EVENT occurs. When a message with the header property CLOSE_EVENT set to true is received, the content of this message is appended to the file, the file is closed and is moved from Working directory to Target directory.
Don't write to file but send to output
The received data is sent to the output port instead of writing into a file. Figure 6 and Figure 7 show the snapshots of the text and binary data sent to output port.
Figure 8: Text data received on output port.
Figure 9: Binary data received on output port.
Append if exists
If the file to which the data is to be written already exists in the Target/Destination directory, data is appended to the content in the existing file. The file being processed will be moved to the Working directory and content received in the input message will be appended to the existing file until FileWriter receives a message with a property COMPLETE set to true. (JMS function setStringProperty() can be used to set the value of a JMS property on a message).
The encoding to be used while writing the file. The following encodings can be used. Figure 8 shows all the encodings that can be used.
Figure 10: Different types of File Encoding
A coding standard used to represent plain text. It is based on the order of English Alphabet.
|Cp1252||This is a character encoding of the Latin alphabet.|
|UTF8||A variable-length character encoding for Unicode.|
|UTF-16||This is a variable-length character encoding for Unicode. The encoding form maps each character to a sequence of 16-bit words.|
|ISO8859_1||ISO 8859-1, more formally cited as ISO/IEC 8859-1 is part 1 of ISO/IEC 8859, a standard character encoding of the Latin alphabet.|
|Multi-byte character encoding systems used for Korean, Japanese, Simplified Chinese, and Traditional Chinese languages respectively.|
For the Monitoring configuration description, please refer the respective section in the Common Configurations page.
These properties are meant for advanced users.
Figure 11: Interaction Configurations panel with the Expert Properties option enabled
Script or a Command that is to be executed after the file processing is finished. A command can be specified by simply typing it in the text area provided against this property. To provide a script file, the file dialog which is shown by clicking the ellipses button can be used.
By default, the component appends the absolute path of the target file to this script/command that is. the absolute path of the target file would be the first argument to this script/command. More arguments for this command could be specified using the property PostProcessing Arguments.
The final command formed by the FileWriter would be:
Arguments that are passed to postprocessing script or command.
Copying all the files present in Error directory to a backup location after the file is processed.
A batch file copyerrors.bat with content copy C:\FileWriter\ErrorDir %2 is written and is placed in C:\. The path of this batch file is specified for the property PostProcessing Command. The backup location (C:\ProcessingFailures) is specified as the value for PostProcessing Arguments.
Let C:\FileWriter\TargetDir\test.txt be the target file. With this configuration, the command formed by FileWriter would be C:\copyerrors.bat C:\FileWriter\TargetDir\test.txt C:\ProcessingFailures. The copy command executed finally would be copy C:\FileWriter\ErrorDir C:\ProcessingFailures which moves all the files in C:\FileWriter\ErrorDir to the backup location C:\ProcessingFailures.
Time interval for PostProcessing script
The maximum interval of time for Post Processing Script to get finished; the value is in milliseconds.
Return data on Output?
Determines if the data written to the file is to be sent onto the output port instead of sending out an XML message containing the details of the file to which the content has been written. Figure 6 and Figure 7 show sample views of the text and binary data sent to the output port. As shown in the figures, enabling this property will send the data in the output message. However, the file details can still be fetched from the message headers of the output message. Refer Table 1 for the description of header properties.
Table 1 shows the descriptions of header properties set by the component on the output message when binary/flat content is processed.
Type of data received on input port
Name of the file to which the data is being written.
Path of the directory which holds the destination file.
Absolute path of the destination file. For a binary file, this property appears only on the message which represents the last chunk of the file.
Determines the final size of the destination file.
Determines if the destination file is readable/writable. For a binary file, these properties appear only on the message which represents the last chunk of the file.
Value of the header property START_EVENT present on the input message to the component. An input message with this property set indicates that this is the first message whose content is to be written to the file represented by the property FileName.
Value of the header property RECORD_INDEX present on the input message to the component. A value 'n' for this property indicates that this is the nth message whose content is to be appended to the file represented by the property FileName
Value of the header property CLOSE_EVENT present on the input message to the component. An input message with this property set indicates that this is the last message whose content is to be appended to the file represented by the property FileName.
Value of the header property NEW present on the input message to the component. An input message with this property set to true indicates that this message holds the first chunk of data to be written to the file represented by the property FileName
Value of the header property COMPLETE present on the input message to the component. An input message with this property set to true indicates that this message holds the last chunk of data to be appended to the file represented by the property FileName
Value of the header property START_INDEX present on the input message to the component. This value represents the offset of the first byte of the chunk which has been currently written to the destination file.
Value of the header property END_INDEX present on the input message to the component. This value represents the offset of the last byte of the chunk which has been currently written to the destination file.
Table 1: Header Properties
Move file to working directory on start?
If a file exists in the target directory, choosing this option would move the file to the working directory and appends the incoming messages to the file.
Elements to Decrypt
Select elements to decrypt in the Input Message.
Refer to the Encrypt Decrypt Configuration section in the Common Configurations page for details.
Input and Output
No schema is set on the input port. If any XML message has to be written into a file then the XML message is directly sent as input message.
When a file is written successfully, FileWriter sends out the file information onto the output port. Figure 9 shows the schema of the output XML message. Table 2 shows the description of the schema elements.
Figure 12: Schema on the output port
Path of the file to which the data has been written
Name of the file to which the data has been written
Path of the directory which holds the output file
The type of output
Specifies if the output file has read access
Specifies if the output file has write access
Size of the output file in bytes
Table 2: Description of Output schema elements
Testing the Interaction Configurations
Interaction configurations can be tested from the CPS by clicking the Test button. Figure 11 and Figure 12 shows the sample input and the corresponding output message respectively.
Figure 13: Sample input
Figure 14: Output generated for input shown in Figure 10.
Writing the input message into to a file and displaying the response contents.
Configure the FileWriter as shown below.
Figure 15: Sample Configuration of FileWriter
Use a Feeder and a Display component to send sample input and check the response respectively.
Use Case Scenario
In a revenue control packet scenario, if an error occurs while parsing the transaction data, an error message is written to a file.
Figure 17: Revenue Control Packet Scenario.
The Event Process demonstrating this scenario is bundled with the installer.
Documentation of the scenario and instructions to run the flow can be found in the Help tab of the flow present in eStudio.