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.


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 Brown
The 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.text
The 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 Brown