Example: adding a user-defined message property for a file-to-message transfer

If we are using Managed File Transfer for message-to-file managed transfers, we can include a user-defined message property for the resulting message.


We can use any of the following methods to define a custom message property:

  • Specify the -md parameter on the transfer request. For more information, see Example: Setting user-defined properties on a file-to-message transfer.

  • Use an Ant task; we can use either fte:filecopy or fte:filemove. The following example is a fte:filecopy task:

    <project xmlns:fte="antlib:com.ibm.wmqfte.ant.taskdefs" default="complete">
    <!-- Initialise the properties used in this script.--> 
    
    <target name="init" description="initialise task properties">
                   <property name="src.file" value="/home/user/file1.bin"/>
                   <property name="dst.queue" value="TEST.QUEUE@qm2"/>
                   <fte:uuid property="job.name" length="8"
    prefix="copyjob#"/>
    </target>
    <target name="step1" depends="init" description="transfer file">
    
    <fte:filecopy cmdqm="qm0@localhost@1414@SYSTEM.DEF.SVRCONN"
                  src="agent1@qm1" dst="agent2@qm2"
                 rcproperty="copy.result">
    
    <fte:metadata>
    <fte:entry name="fileName" value="${FileName}"/>
    </fte:metadata>
    
    <fte:filespec srcfilespec="${src.file}" dstqueue="${dst.queue}"
    dstmsgprops="true"/>
    
    </fte:filecopy>
    
    </target>
    </project>
    
    
    
  • Use a resource monitor and variable substitution. The following example shows some transfer task XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <monitor:monitor
    xmlns:monitor="http://www.ibm.com/xmlns/wmqfte/7.0.1/MonitorDefinition"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="5.00"
    xsi:schemaLocation="http://www.ibm.com/xmlns/wmqfte/7.0.1/MonitorDefinit ion ./Monitor.xsd">
     <name>METADATA</name>
     <pollInterval units="minutes">5</pollInterval>
     <batch maxSize="5"/>
     <agent>AGENT1</agent>
     <resources>
       <directory recursionLevel="0">e:\temp</directory>
     </resources>
     <triggerMatch>
       <conditions>
         <allOf>
           <condition>
             <fileMatch>
               <pattern>*.txt</pattern>
             </fileMatch>
           </condition>
         </allOf>
       </conditions>
     </triggerMatch>
     <tasks>
       <task>
         <name/>
         <transfer>
           <request version="5.00"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="FileTransfer.xsd">
             <managedTransfer>
               <originator>
                 <hostName>mqjason.raleigh.ibm.com.</hostName>
                 <userID>administrator</userID>
               </originator>
               <sourceAgent QMgr="AGENTQM" agent="AGENT1"/>
               <destinationAgent QMgr="AGENTQM" agent="AGENT2"/>
               <transferSet priority="0">
                 <metaDataSet>
                   <metaData key="FileName">${FileName}</metaData>
                 </metaDataSet>
                 <item checksumMethod="MD5" mode="text">
                   <source disposition="delete" recursive="false">
                     <file>${FilePath}</file>
                   </source>
                   <destination type="queue">
                     <queue persistent="true"
    setMqProps="true">TEST.QUEUE@AGENTQM</queue>
                   </destination>
                 </item>
               </transferSet>
               <job>
                 <name>Metadata_example</name>
               </job>
             </managedTransfer>
           </request>
         </transfer>
       </task>
     </tasks>
     <originator>
       <hostName>mqjason.raleigh.ibm.com.</hostName>
       <userID>administrator</userID>
     </originator>
    </monitor:monitor> 
    

Parent topic: Example: Setting user-defined properties on a file-to-message transfer


Related tasks


Related information