What to do if destination files created by a transfer started by a queue resource monitor contain the wrong data

You can create a resource monitor to monitor a queue and transfer a message or a group of messages on a queue to a file. The file name can be specified by using the MQMD message descriptors on the message or the first message in a group. If a message-to-file transfer fails and the message or group is left on the queue, the next time the monitor is triggered it might result in files being created that contain the wrong data.

Why this problem occurs

  1. A message-to-file transfer fails and the message or group is left on the queue.
  2. A new message or group arrives on the queue.
  3. The new message or group triggers the resource monitor.
  4. The resource monitor creates a new transfer that uses the MQMD message descriptors from the new message or group and the data from the first message or group on the queue.
  5. Files are created that contain the wrong data.

Avoiding this problem

To avoid experiencing this problem, you must manually create a transfer definition file by using the fteCreateTransfer command and edit the <queue> element of the file to include the attribute groupId=${GROUPID}. Then submit the transfer definition file by using the fteCreateMonitor command.

Example

In this example: the source agent, which is also the monitoring agent, is called AGENT_MON; the destination agent is called AGENT_DEST; the destination file name is /out/files/${WMQFTEFileName}. This example requires that the message has the MQMD message descriptor WMQFTEFileName set. The queue being monitored is LIVE_QUEUE.

  1. Create a transfer definition file by running the following command:
    fteCreateTransfer -sa AGENT_MON -da AGENT_DEST -df "/out/files/${WMQFTEFileName}" 
                   -de error -gt /tmp/TransferDefinition1.xml -sqgi -sq LIVE_QUEUE
    The transfer definition file /tmp/TransferDefinition1.xml is generated.
  2. Edit the <queue> element to include the attribute groupId=${GROUPID}. Change the line
    
    <queue useGroups="true">LIVE_QUEUE</queue>
    to
    
    <queue useGroups="true" groupId="${GROUPID}">LIVE_QUEUE</queue>
    This attribute is required so that the transfer reads the group or message that triggered the transfer from the queue instead of the first group or message on the queue.
  3. Create the monitor by running the following command:
    fteCreateMonitor -ma AGENT_MON -mq LIVE_QUEUE -mn QueueMon1 -mt /tmp/TransferDefinition1.xml
                  -tr completeGroups -dv WMQFTEFileName=UNKNOWN
    This monitor polls the queue every 60 seconds to see if a new group or message has arrived on the queue.