Example: Splitting a text file with a regular expression delimiter and including the delimiter in the messages
Transfer a single text file to multiple messages by splitting the file at each match of a given Java™ regular expression and include the regular expression match in the resulting messages. To do this you use the -dqdt and -qi parameters of the fteCreateTransfer command.
About this task
Customer name: John Smith
Customer contact details: john@example.net
Customer number: 314
Customer name: Jane Brown
Customer contact details: jane@example.com
Customer number: 42
Customer name: James Jones
Customer contact details: jjones@example.net
Customer number: 26
The regular expression that specifies where to split the
file is Customer\snumber:\s\d+, which matches the
text Customer number:followed by any number of digits. Regular expressions specified at the command line must be enclosed in double quotation marks to prevent the command shell evaluating the regular expression. The regular expression is evaluated as a Java regular expression. For more information, see Regular expressions used by WebSphere MQ File Transfer Edition.
By default the number of characters that a regular expression can match is set to five. The regular expression used in this example matches strings that are longer than five characters. To enable matches that are longer than five characters edit the agent properties file to include the property maxDelimiterMatchLength.
By default, the text that matches the regular expression is not included in the messages. To include the text that matches the regular expression in the messages, as in this example, use the -qi parameter. The source file is located on the same system as the source agent AGENT_NEPTUNE, which connects to the queue manager QM_NEPTUNE. The destination queue, RECEIVING_QUEUE, is located on the queue manager QM_MERCURY. QM_MERCURY is also the queue manager used by the destination agent AGENT_MERCURY. The transfer splits the source file into sections and writes each of these sections to a message on RECEIVING_QUEUE.