Scenario 2: Transmitting XML files via a MOM server - 6.3

Talend Open Studio for Big Data Components Reference Guide

EnrichVersion
6.3
EnrichProdName
Talend Open Studio for Big Data
task
Data Governance
Data Quality and Preparation
Design and Development
EnrichPlatform
Talend Studio

This scenario describes a five-component Job composed of two subjobs that sends XML files from a local folder to a MOM queue, and then fetches the files from the MOM queue and displays the contents of the files on the console.

Dropping and links the components

  1. From the Palette, drop the following components one after another onto the design workspace: tFileList, tFileInputXML, tMomOutput, tMomInput, and tLogRow.

  2. Connect tFileList to tFileInputXML using a Row > Iterate link, and connect tFileInputXML to tMomOutput using a Row > Main link to form the first subjob. This subjob will read each XML file in a given folder and send it to a MOM queue.

  3. Connect tMomInput to tLogRow using a Row > Main link to form the second subjob. This subjob will fetch the XML files from MOM queue and display the file contents on the console.

  4. Connect tFileInputXML to tMomInput using a Trigger > On Component Ok connection to link the two subjobs.

Configuring the first subjob

Configuring the input components
  1. Double-click the tFileList component to open its Basic settings view.

  2. In the Directory field, enter the path to the directory to read XML files from, or browse to the path by clicking the [...] button next to the field.

  3. Select Use Glob Expressions as Filemask check box, add a new line in the Files field by clicking the [+] button, and enter "*.xml" as the file mask so that all XML files in the directory will be used. Keep all the other settings as they are.

  4. Double-click the tFileInputXML component to open its Basic settings view.

  5. Click the [...] button next to Edit schema to open the [Schema] dialog box.

  6. Click the [+] button to add a column, give it a name, message in this example, and select Document from the Type list to handle XML format files. Then, click OK to close the dialog box.

  7. In the File name/Stream field, press Ctrl+Space to access the global variable list, and select tFileList_1.CURRENT_FILEPATH to loop on the context files' directory.

  8. In in the Loop XPath query fields, enter "/" to define the root as the loop node of the input files' structure; in the Mapping table, fill the XPath query column with "." to extract all data from context node of the source files, and select the Get Nodes check box to build a Document type data flow.

Configuring the tMomOutput component
  1. Double-click the tMomOutput component to open its Basic settings view.

  2. Select WebSphere MQ from the MQ server list, and enter the host name or IP address of the MQ server and the port number.

  3. Enter the login authentication information in the Username and Password fields, and enter the channel name of the transmission queue in the Channel field.

  4. As we are handling file messages, select Text Message from the Message Body Type list.

  5. Click Sync columns to retrieve the schema structure from the preceding component.

  6. Fill in the queue manager and message queue details in the corresponding fields, and leave the other settings as they are.

Configuring the second subjob

  1. Double-click the tMomInput component to open its Basic settings view.

  2. Set the basic parameters of the component using the same settings you have done in the tMomOutput component, including the MQ server details, login authentication details, channel, message body type, queue manager and message queue.

  3. Click the [...] button next to Edit schema to open the [Schema] dialog box.

  4. From the Type list for the message column, select Document to handle XML format files, and then click OK to close the dialog box.

Saving and executing the Job

  1. Press Ctrl+S to save your Job.

  2. Press F6 or click Run on the Run tab to execute the Job.

    The XML files in the specified folder are written to the message queue and then retrieved from the queue. The contents of the files are displayed on the console.