Which of the following file modes does retains file data and append new data

If a failure occurs during the final transfer of the file to the output directory, you can choose whether the file is deleted, moved to the failure directory (mqsifailure), renamed before being moved to the failure directory, or no action is taken. The chosen action is not effective if the file is being written directly to the output file on your local system and the FTP property is cleared.

You can specify that the FileOutput node transfers files to a remote FTP or SFTP server as part of file processing. If the file is successfully transferred, it can be deleted from the local file system, or, optionally, retained for the rest of the file processing to occur as usual. The server is identified by the Remote server and port property on the node. Alternatively, you can override the node property by setting a value in the local environment. You can also use the local environment to specify commands to run before or after an FTP or SFTP transfer finishes. For more information, see Local environment overrides for the remote server on the FileOutput node.

During the file transfer operation, the FileOutput creates the destination file. However, the destination file is readable before the file transfer is complete. Therefore, ensure that remote applications do not read the file until the file transfer is complete.

When multiple records are written, no file processing occurs until a message is received on the Finish File terminal of the node. Any message received on the Finish File terminal causes the file to be moved from the transit directory to either the specified output directory or to a remote FTP or SFTP directory.

It is not an error if file processing is initiated when there is no file in the transit directory.

If you set the Record definition property to Record is Whole File on the Records and Elements tab, messages received on the Finish File processing are ignored because the file has already been processed.

On Linux®, UNIX, and z/OS® systems, the permissions that new files are created with are determined by the umask value. The minimum permission required by IBM® Integration Bus for all files, including internal configuration files, is for user and group to have read/write access (660). Consequently, the umask value is set to 0006 by default.

You can override the default umask value by using the following environment variables, although IBM Integration Bus will try to ensure that user and group maintain read/write access:MQSI_SET_DFE_UMASK=nnnnUsing this environment variable, you can override the umask for new files that are created by integration server processes. nnnn is the octal representation of the desired file creation mask.MQSI_UMASK_COPY=nIf this environment variable is set to any value and MQSI_SET_DFE_UMASK is not set, the umask value is copied from the umask setting of the shell environment, which is often the system default value.

Note:

Care is required when overriding the umask value to ensure that directories and files created by IBM Integration Bus have a minimum permission of 660 and 770 respectively. A good understanding of umask is needed before using the overrides. If the permissions of newly created directories and files is overly restricted, IBM Integration Bus might not be able to restart successfully.

Message propagation

For every message received on the In terminal and successfully processed by the node, a copy is propagated to the Out terminal for further processing if the terminal is attached.

For every message received on the Finish File terminal and successfully processed by the node, a copy is propagated to the End of Data terminal for further processing if the terminal is attached.

When the FileOutput node propagates a message, either to the Out terminal or to the End of Data terminal, it stores information in the LocalEnvironment.WrittenDestination.File message tree. This table describes the LocalEnvironment.WrittenDestination.File elements:

Element NameElement Data TypeDescriptionDirectoryCHARACTERAbsolute path of the output directory in the form used by the file system of the integration node. For example, on Windows systems, the directory path starts with the drive letter prefix (such as C:).NameCHARACTERName of the output file.ActionCHARACTERPossible values are:

  • Replace if an output file of the same name is replaced.
  • Create if a new output file is created.
  • Append if this message is associated with a record that is added to an output file.
  • Finish if a Finish File message is received and no file is found to finish (for example, if Record is Whole File is specified and a message is sent to the Finish File terminal).
  • Transmit if the file was transferred by FTP or SFTP and the file was not retained.
TimestampCHARACTERThe date and time, in character string form, when the node started to process this file. This value prefixes the names of files that are archived if you set the Action if file exists property to Time Stamp, Archive, Replace Existing File and Append to Existing File on the Basic tab.

Multiple instances

Several message flows might write to the same file, which can happen where there are additional instances of the flow, or where multiple flows contain FileOutput nodes. The FileOutput node permits only a single instance, within an integration server and between integration servers, to write to a file at the same time. While a record is being written, all other instances in the integration server must wait. The order in which instances gain access is not defined.

When the file is complete, the first instance to gain access processes it, and other instances do not find the file. The Action element of the LocalEnvironment.WrittenDestination.File message tree is set to Finish for all instances that fail to discover the file in the transit directory.

The FileOutput node terminals are described in the following table.

TerminalDescriptionInThe input terminal that accepts a message for processing by the node.Finish FileThe input terminal that accepts a message that triggers the final processing of a file.OutThe message received on the In terminal is propagated to this terminal if the record is written successfully. The message is unchanged except for status information in the Local Environment.End of DataThe message received on the Finish File terminal is propagated to this terminal if the file is processed successfully.FailureThe output terminal to which the message is routed if a failure is detected when a message is propagated.

The following tables describe the node properties that you can set on a specified tab. The column headed M indicates whether the property is mandatory (marked with an asterisk if you must enter a value when no default is defined); the column headed C indicates whether the property is configurable (you can change the value when you add the message flow to the BAR file to deploy it).

The FileOutput node Description properties are described in the following table.

PropertyMCDefaultDescriptionNode nameNoNoFileOutputThe name of the node.Short DescriptionNoNo A brief description of the node.Long DescriptionNoNo Text that describes the purpose of the node in the message flow.

The FileOutput node Basic properties are described in the following table.

PropertyMCDefaultDescriptionmqsiapplybaroverride command propertyAction on final file processing failureNoNoNo ActionThe action that the node takes with the output file if the final processing of a file fails. Valid options are:

  • No action
  • Move to mqsifailure Subdirectory The file is moved to the failure subdirectory of the output directory. The name of this subdirectory is mqsifailure. If the input directory is /var/fileinput, the absolute path of the failure subdirectory is /var/fileinput/mqsifailure. If this subdirectory does not exist, the broker creates it when it first tries to move a file there. If the file cannot be moved to this subdirectory, perhaps because a file of the same name exists there, the node adds the current date and time to the file name and makes a second attempt to move the file. If this second attempt fails, the node stops processing. Messages BIP*** and BIP**** are issued. Resolve the problem with the subdirectory or file before attempting to restart the message flow.
  • Delete The file is deleted if it can not be written to the output directory following a message received on the Finish File terminal.
  • Add Time Stamp and Move to mqsifailure Subdirectory the current date and time are added to the file name, and then the file is moved to the failure subdirectory.
 DirectoryNoYesNoneSpecify the output directory in which the FileOutput node places its files. Specify the directory as an absolute or relative directory path. If the directory path is relative, it is based on the directory specified in the environment variable MQSI_FILENODES_ROOT_DIRECTORY. For example:
  • On Windows: C:\fileoutput
  • On UNIX: /var/fileoutput
To write files in the directory that is identified by MQSI_FILENODES_ROOT_DIRECTORY, ensure that you specify a value of . (a period) in this property.

You can override the output directory path to be used by setting values in the current message. For more information, see the Request tab properties.

outputDirectoryFile name or patternNoYesNoneSpecify a file name pattern. This property defines the name of the file that is created by the FileOutput node. The value is either a specific file name or a character sequence (pattern) that matches a file name. Only patterns with a single wildcard character (the asterisk, *) are allowed in this property field. The file name to be used is determined in the following way:
  • If the file name contains no wildcard, the value of this property is the name of the file created. This value must be a valid file name on the file system or the FTP file system that hosts the integration node to which the message flow is deployed.
  • If the file name contains a single wildcard character, the value of the element LocalEnvironment.Wildcard.WildcardMatch in the current message replaces the wildcard character, and the resulting value is the name of the file created. This value must be a valid file name on the file system or the FTP file system that hosts the integration node to which the message flow is deployed. If the WildcardMatch value is not found, the wildcard character is replaced by an empty string.
You can override the name of the file by setting values in the current message. For more information, see the Request tab properties. If the File name or pattern property is empty, you must override the name by using the current message. Wildcard substitution occurs only if this property is not overridden in this way.

File names are passed to the file system to which the integration node has access and must adhere to the conventions of these file systems. For example, file names on Windows systems are not case-sensitive; while on UNIX systems, they are.

outputFilenameMode for writing to fileYesNoStage in transit directorySpecify if the file must be staged or written to directly. Select one of the following options:
  • Stage in transit and move to output directory on Finish File
  • Write directly to the output file
 Action if file existsYesNoReplace Existing FileSpecify how the file is to be processed when it is complete. Select one of the following options:
  • Replace Existing File (the default value) specifies that if a file of the same name exists in the output directory, the new file replaces it.
  • Append to Existing File moves the output file to the transit directory and appends the file contents to the file. The file is moved back to the output directory when the append is finished.
  • Fail if File Exists specifies that a new file is created, and that if a file of the same name exists in the output directory, the new file remains in the transit directory and exception BIP3307 is produced.
  • Archive and Replace Existing File specifies that if any file of the same name exists in the output directory, it is moved to the archive directory before the new file is placed in the output directory. If any file of the same name exists in the archive directory, an exception is produced.
  • Time Stamp, Archive, and Replace Existing File specifies that if a file of the same name exists in the output directory, its name is augmented with a time stamp (a character-based version of the date and time) before being moved to the archive directory. The format of the time stamp is yyyyMMdd_HHmmss_SSSUUU, in UTC time, where UUU is an additional ID to ensure that the time stamp is unique.
 Replace duplicate archive filesYesNoClearedSelect the Replace duplicate archive files check box to specify that, in cases where Archive and Replace Existing File or Time Stamp, Archive and Replace Existing File is specified in Action if file exists, files moved to the archive directory replace files that exist there already with the same name.

By default, this check box is cleared. If this check box is not selected, and there is already a file in the archive directory with the same name as a file that is to be moved there, an exception is produced, and the new file remains in the transit directory.

 

The FileOutput node Request properties are described in the following table.

These properties specify the location of the data to be written, and control information that overrides the Directory and File name or pattern properties on the Basic tab. You can specify the properties on this tab as XPath or ESQL expressions. Content assist is available in the properties pane and also in the XPath Expression Builder, which you can open by using the Edit button to the right of each property.

PropertyMCDefaultDescriptionmqsiapplybaroverride command propertyData locationYesNo$BodySpecify the input data location, which is the location in the input message tree that contains the record to be written to the output file. The default value is $Body, meaning the entire message body ($InputRoot.Body).

When you specify this property, and the data in the message tree that it identifies is owned by a model-driven parser, such as the MRM parser or XMLNSC parser, consider the following factors.

  • If you are using MRM CWF format, ensure that the identified message tree exists as a message definition. If this element is defined as a global element only, exceptions BIP5180 and BIP5167 are produced.
  • If you are using MRM TDS format, serialization of the identified message is successful if the element is defined as a global element or message. However, if the identified field is not found as a global element or message, the following conditions apply:
    • If the field is a leaf field in the message tree, the field is written as self-defining. No validation occurs even if validation is enabled.
    • If the field is a complex element, an internal exception is generated (BIP5522), indicating that the logical type cannot be converted to a string.
  • If you are using MRM XML, the events are similar as for the MRM TDS format except that, if the field is a complex element, it is written as self-defining.
  • If you use the XMLNSC parser, no validation occurs even if validation is enabled.

 Request directory property locationYesYes$LocalEnvironment/Destination/File/DirectorySpecify the location of the value to override the Directory property on the Basic tab. If you do not specify a location, the default value is $LocalEnvironment/Destination/File/Directory. If you specify a location but the element is empty or missing, the Directory property is used. The element has a data type of CHARACTER and is an absolute or relative directory path. Use the path separator character ('/' or '\') according to the file system on which the integration node runs. Trailing path separator characters are ignored. Relative directory paths are based on the value of the MQSI_FILENODES_ROOT_DIRECTORY environment variable.requestDirectoryLocationRequest file name property locationYesYes$LocalEnvironment/Destination/File/NameSpecify the location of the value to override the File name or pattern property on the Basic tab. The element has a data type of CHARACTER and is an explicit file name. No wildcard substitution occurs for this value. If the property is not in the local environment when the message arrives in the In or Finish File terminal of the node, then the default is to use the File name or pattern property on the Basic tab.requestNameLocation

The FileOutput node Records and Elements properties are described in the following table.

These properties specify how the FileOutput node writes the record derived from the message.

PropertyMCDefaultDescriptionRecord definitionYesNoRecord is Whole FileSpecify how the records are placed in the output file. Select one of the following options:

  • Record is Whole File specifies that the file is to contain a single record. The file is finished immediately after the record is written; the FileOutput node does not wait for a message on the Finish File terminal. This value is the default.
  • Record is Unmodified Data specifies that records are accumulated in a file with neither padding or delimiters applied. The file is finished only when a message is received on the Finish File terminal.
  • Record is Fixed Length Data specifies that records are padded to a given length if necessary and accumulated in a file by concatenation. You specify this length in the Length property. If the record is longer than the value specified in Length, the node produces an exception. Use the Padding byte property to specify the byte to be used for padding the message to the required length. Records are added to this file until a message is received on the Finish File terminal.
  • Record is Delimited Data to specify that records are separated by a delimiter and accumulated by concatenation. The delimiter is specified by the Delimiter, Custom delimiter, and Delimiter type properties. Records are added to this file until a message is received on the Finish File terminal.
LengthYesNo80Specify the length (in bytes) of records when Record is Fixed Length Data is specified in Record definition. Records that are longer than this value cause an exception to be produced. This value must be in the range 1 byte through 104857600 bytes (100 MB). The default value is 80 bytes.Padding byteYesNoX'20'When Record is Fixed Length Data is specified in Record definition, use the Padding byte property to specify the byte to be used when padding records to the specified length if they are shorter than this length. Specify this value as two hexadecimal digits. The default value is X'20'.DelimiterYesNoBroker System Line EndSpecify the delimiter to be used if you specify Record is Delimited Data in Record definition. Select one of the following options:
  • Broker System Line End specifies that a line end sequence of bytes is used as the delimiter, as appropriate for the file system on which the integration node is to run. For example, on Windows systems, the delimiter is a 'carriage-return, line-feed' pair (X'0D0A'); on UNIX systems, it is a single 'line-feed' byte (X'0A'); on z/OS systems, it is a 'newline' byte (X'15'). This value is the default.
  • Custom Delimiter specifies that the explicit delimiter sequence defined in the Custom delimiter property is to be used to delimit records.
Custom delimiterNoNoNoneSpecify the delimiter sequence of bytes to be used to delimit records when Custom Delimiter is specified in the Delimiter property. Specify this value as an even-numbered string of hexadecimal digits. The default value is X'0A' and the maximum length of the string is 16 bytes.Delimiter typeYesNoPostfixIf you set the Record definition property to Record is Delimited Data, use Delimiter type to specify how the delimiter is to separate records. Select one of the following options:
  • Postfix specifies that the delimiter is added after each record that is written. This value is the default.
  • Infix specifies that the delimiter is inserted only between any two adjacent records.

The FileOutput node Validation properties are described in the following table.

For a full description of these properties, see Validation properties.

PropertyMCDefaultDescriptionmqsiapplybaroverride command propertyValidateNoYesInheritSpecify whether validation takes place. Valid values are:

  • None
  • Content and Value
  • Content
  • Inherit
validateMasterFailure actionNoNoExceptionSpecifies what happens if validation fails. You can set this property only if you set Validate to Content or Content and Value. Valid values are:
  • User Trace
  • Local Error Log
  • Exception
  • Exception List
 

The FileOutput node FTP properties are described in the following table.

To transfer files to an FTP, FTPS, or SFTP server, select the Remote Transfer property, then set the properties described in this table.

PropertyMCDefaultDescriptionmqsiapplybaroverride command propertyRemote transferNoYesClearedTo transfer files to an FTP, FTPS, or SFTP server, select Remote Transfer, then set the other properties in this table.fileFtpTransfer protocolNoYesFTPThis property specifies the protocol to be used for remote transfer. Valid values are:

  • FTP
  • SFTP
  • FTPS
remoteTransferTypeRemote server and portNoYesNoneThis property can have either of the following values:
  • The IP address or name (and, optionally, the port number) of a remote FTP, FTPS, or SFTP server
  • The name of a configurable service of type FtpServer

Specify the IP address and port number of the FTP, FTPS, or SFTP server to be used, by using the following syntax:

  • IP_address_or_URL or
  • IP_address_or_URL:port_number
If you specify the IP address in IPv6 format, ensure that you enclose it in square brackets, for example:
  • [12a::13bd:24cd] or
  • [12a::13bd:24cd]:123 where 123 is the port number

If you are using FTP or FTPS and you do not specify a port number, 21 is assumed. If you are using SFTP and you do not specify a port number, a port number of 22 is assumed. However, if an FtpServer configurable service is defined, you can enter the name of the configurable service in this field. If a configurable service name is specified, any or all of the other remote transfer properties on the FTP tab can be overridden by the configurable service. For information about how an FtpServer configurable service definition and the properties on this tab interact, see FtpServer configurable service.

You can override this property by setting the location of the server in the local environment. For more details, see Local environment overrides for the remote server on the FileOutput node.

fileFtpServerSecurity identityNoYesNoneSpecify the name of a security identity that has been defined by using the mqsisetdbparms command. The user identifier and password that are to be used to log on to the FTP, FTPS, or SFTP server are obtained from this definition. The name of the definition must have the prefix ftp::. The value of this property is overridden by the value in the FtpServer configurable service property securityIdentity, if it is set.fileFtpUserServer directoryNoYes"."Specify the directory on the FTP, FTPS, or SFTP server to which to transfer files. The default value is . (a period), which indicates the default directory after logon. If you specify a relative path, the directory is based on the default directory after FTP, FTPS, or SFTP logon. Ensure that the syntax of the path conforms to the file system standards in the FTP, FTPS, or SFTP server. The value of this property is overridden by the value in the remoteDirectory property of the FtpServer configurable service, if it is set. If the directory specified in this field does not exist on the remote server, the node attempts to create it.

Which of the following file mode is used to append to end of file?

"Appending" means adding something to the end of another thing. The "a" mode allows you to open a file to append some content to it. And we want to add a new line to it, we can open it using the "a" mode (append) and then, call the write() method, passing the content that we want to append as argument.

Which mode is used to retain its previous data and allowing to add new data?

On the other NOTES 2022-23 Page 6 COMPUTER SCIENCE - CLASS XII 24 hand, in append mode, new data will be added at the end of the previous data as the file object is at the end of the file.

Which of the following access mode is used for opening a file for appending in the binary format?

To open a file in binary format, add 'b' to the mode parameter. Hence the "rb" mode opens the file in binary format for reading, while the "wb" mode opens the file in binary format for writing.

Which among following is used to append the content to the current content of the file?

appendFile() method is used to append the specified content to a file. If the file does not exist, it creates the file.