Scenario: Utilizing .NET in Talend - 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 three-component Job that uses a DLL library containing a class called Test1.Class1 Class and invokes a method on it that processes the value and output the result onto the console.

Prerequisites

Before replicating this scenario, you need first to build up your runtime environment.

  • Create the DLL to be loaded by tDotNETInstantiate

    This example class built into .NET reads as follows:

    using System;
    using System.Collections.Generic;
    using System.Text;
    
    
    namespace Test1
    {
        public class Class1
        {
            string s = null;
            public Class1(string s)
            {
                this.s = s;
            }
    
            public string getValue()
            {
                return "Return Value from Class1: " + s;
            }
    
        }
        }

    This class reads the input value and adds the text Return Value from Class1: in front of this value. It is compiled using the latest .NET.

  • Install the runtime DLL from the latest .NET. In this scenario, we use janet-win32.dll on Windows 32-bit version and place it in the System32 folder.

    Thus the runtime DLL is compatible with the DLL to be loaded.

Connecting components

  1. Drop the following components from the Palette to the design workspace: tDotNETInstantiate, tDotNETRow and tLogRow.

  2. Connect tDotNETInstantiate to tDotNETRow using a Trigger On Subjob OK connection.

  3. Connect tDotNETRow to tLogRow using a Row Main connection.

Configuring tDotNETInstantiate

  1. Double-click tDotNETInstantiate to display its Basic settings view and define the component properties.

  2. Click the three-dot button next to the Dll to load field and browse to the DLL file to be loaded. Alternatively, you can fill the field with an assembly. In this example, we use :

    "C:/Program Files/ClassLibrary1/bin/Debug/ClassLibrary1.dll""

  3. Fill the Fully qualified class name field with a valid class name to be used. In this example, we use:

    "Test1.Class1"

  4. Click the plus button beneath the Value(s) to pass to the constructor table to add a new line for the value to be passed to the constructor.

    In this example, we use:

    "Hello world"

Configuring tDotNETRow

  1. Double-click tDotNETRow to display its Basic settings view and define the component properties.

  2. Select Propagate data to output check box.

  3. Select Use an existing instance check box and select tDotNETInstantiate_1 from the Existing instance to use list on the right.

  4. Fill the Method Name field with a method name to be used. In this example, we use "getValue", a custom method.

  5. Click the three-dot button next to Edit schema to add one column to the schema.

    Click the plus button beneath the table to add a new column to the schema and click OK to save the setting.

  6. Select newColumn from the Output value target column list.

Configuring tLogRow

  1. Double-click tLogRow to display its Basic settings view and define the component properties.

  2. Click Sync columns button to retrieve the schema defined in the preceding component.

  3. Select Table in the Mode area.

Save your Job and press F6 to execute it.

From the result, you can read that the text Return Value from Class1 is added in front of the retrieved value Hello world.