Example: Splitting a text file into multiple messages using a regular expression delimiter
Transfer a single text file to multiple messages by splitting the file at each match of a given Java regular expression. To do this we use the -dqdt parameter of the fteCreateTransfer command.
About this task
The file is split into variable-length sections, each of which is written to an individual message. The text file is split at each point where the text in the file matches a given regular expression. The source file is called /tmp/names.text and has the following contents:Jenny Jones,John Smith,Jane BrownThe regular expression that specifies where to split the file is the comma character (,).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.
Procedure
Type the following command:fteCreateTransfer -sa AGENT_NEPTUNE -sm QM_NEPTUNE -da AGENT_MERCURY -dm QM_MERCURY -dq RECEIVING_QUEUE -t text -dqdp postfix -dqdt "," /tmp/names.textThe source agent, AGENT_NEPTUNE, reads the data from the file /tmp/names.text and transfers this data to the destination agent, AGENT_MERCURY. The destination agent, AGENT_MERCURY, writes the data to three persistent messages on the queue RECEIVING_QUEUE. These messages all have the same IBM MQ group ID and the last message in the group has the IBM MQ LAST_MSG_IN_GROUP flag set. The data in the messages is as follows.
- First message:
Jenny Jones- Second message:
John Smith- Third message:
Jane BrownParent topic: Transfer data from files to messages
Related concepts
Related tasks
- Configure an agent to perform file-to-message transfers
- Example: Transferring a single file to a single message
- Example: Splitting a single file into multiple messages by length
- Example: Splitting a text file with a regular expression delimiter and including the delimiter in the messages
- Example: Setting IBM MQ message properties on a file-to-message transfer
- Example: Setting user-defined properties on a file-to-message transfer
- Starting a new file transfer
Related reference
Related information