Before you start:This example
is an extension of the example described in
Using a local file as input for your message flow and
it describes how to use a
FileInput node
in a message flow. The instructions assume that you are using a
Windows operating system and that
you have created a message flow containing a
FileInput node. You also require
the following resources:
- An FTP or SFTP server. Ensure
that an FTP or SFTP server exists,
with the following settings:
- Server
- ftpserver.hursley.abc.com
- Port
- 21 (for FTP)
or 22 (for SFTP)
- Working directory
- /ftpfileinput
- Userid
- myuserid
- Password
- mypassword
These values are for the purposes of this example
only. If you use other values, record them so that you can set the
appropriate values during the task.
- A security identity. Use the mqsisetdbparms command to define a security identity called
myidentity for your user and password details.
If you want to connect to an FTP server, the security identity
must have an
ftp:: prefix, to enable the file nodes to
find the identity definition. For example, use the following command for
a broker called
MyBroker:
mqsisetdbparms MyBroker -n ftp::myidentity -u myuserid -p mypassword
If you want to connect to an SFTP server, the security
identity must have an
sftp:: prefix, as shown in the
following
example:
mqsisetdbparms MyBroker -n sftp::myidentity -u myuserid -p mypassword
You can also configure a connection to an SFTP server to use
public key authentication, by specifying an SSH identity file and pass
phrase, instead of a password. For
example:
mqsisetdbparms MyBroker -n sftp::myidentity -u myuserid -i identity_file -r passphrase
To check what security credentials are already set,
use the mqsireportdbparms
command; see Checking the security credentials that are used by an integration node.
For more
information about configuring connections to an SFTP server, see Transferring files securely by using SFTP.
- An input file. To follow this example scenario, create an input
file called test_input1.xml with the following
content:
<Message>test1</Message>
<Message>testtwo</Message>
<Message>testthree</Message>
Each line ends with
a line terminator that is suitable for the system on which the FTP or SFTP server is found. Do not put
this file in the input directory but, instead, put it in the FTP or SFTP server directory /ftpfileinput.
- A message set. This example uses a message set called xml1,
which uses the XMLNSC parser. Message set xml1 models
messages of the following form:
<Message>...</Message>
Complete the following steps:
- Set the required node properties on the FileInput node. The
following table summarizes the FileInput node properties that
you must set, the tab on which they are displayed, whether they are
mandatory, and the required values.
Tab |
Property |
Value |
Basic |
Input directory |
C:\FileInput\TestDir If
the input directory does not exist, no files are processed, even if
you are processing files over FTP or SFTP.
|
File name or
pattern |
test_input1.xml |
Action on successful
processing |
Move to
Archive Subdirectory |
Replace duplicate
archive files |
Selected |
Input Message Parsing |
Message domain |
XMLNSC |
Message
model |
xml1 |
Polling |
Polling interval |
3 |
Retry |
Action on failing
file |
Add Time
Stamp and Move to Backout Subdirectory |
Records and Elements |
Record detection |
Delimited |
Delimiter |
DOS or UNIX
Line End |
Delimiter type |
Postfix |
FTP |
Remote transfer |
Selected |
Transfer
protocol |
FTP or SFTP |
Remote server
and port |
ftpserver.hursley.abc.com |
Security identity |
myidentity |
Server directory |
/ftpfileinput |
Transfer mode |
ASCII (for FTP only) |
Scan delay |
45 |
If you used other values for your FTP or SFTP server resource, enter those values. The settings
used here are identical to those used in the example in Using a local file as input for your message flow, except that the Remote transfer property
has been selected and there are now properties on the FTP tab.
If you clear the Remote transfer property,
the node operates as it does in the example in Using a local file as input for your message flow;
the properties on the FTP tab remain set but
are ignored.
- Deploy the message flow to the broker. See Packaging and deploying.
The following actions occur when you perform these steps:
- The file test_input1.xml is transferred from
the FTP or SFTP server directory
(/ftpfileinput) to the local directory (C:\FileInput\TestDir).
The file is deleted from the FTP or
SFTP server directory.
- The FileInput node
detects records that end with a DOS or UNIX line
end and creates a message for each one that it finds, as defined by
the properties on the Records and elements tab.
The node propagates three messages to the message flow that is attached
to the Out terminal:
- If a node is attached to the End of Data terminal, the End of
Data message is propagated after the last record in the file has been
processed.
- When processing is complete, the file test_input1.xml is
moved to the mqsiarchive subdirectory C:\FileInput\TestDir\mqsiarchive.
If a file called test_input1.xml exists in the mqsiarchive subdirectory,
it is overwritten.
- If the message flow fails, retry processing is attempted according
to the values set in the properties of the FileInput node. In this example
task, a time stamp is added to the file name and the file is moved
to the mqsibackout directory. Here is an example
of the path to such a file: C:\FileInput\TestDir\mqsibackout\20070928_150234_171021_test_input1.xml.
If an error occurs on the FTP side, stating that access
is denied, a 0–byte file is created and moved to the mqsibackout directory.
A 0–byte file is created in the mqsibackout directory for every FTP
attempt that fails.
Because the Remote transfer property
is selected, the FTP scan delay of 45 seconds overrides the polling
interval of 3 seconds.
For more information, see Controlling how files are separated into records, which shows the effects
of specifying other combinations of values in the Record detection, Delimiter, and Delimiter type properties of the FileInput node.
The following
samples also show how to use this node:
You can view information about samples only when you use the product documentation that is integrated with the IBM Integration Toolkit or the online product documentation. You can run samples only when you use the product documentation that is integrated with the IBM Integration Toolkit.