July 30, 2023

tDotNETRow – Docs for ESB 7.x

tDotNETRow

Facilitates data transform by utilizing custom or built-in .NET
classes.

tDotNETRow sends data to and
from libraries and classes within .NET or other custom DLL files.

tDotNETRow Standard properties

These properties are used to configure tDotNETRow running in the Standard Job framework.

The Standard
tDotNETRow component belongs to the DotNET family.

The component in this framework is available in all Talend
products
.

Basic settings

Schema and Edit
schema
A schema is a row description, it defines the number of fields to be
processed and passed on to the next component. The schema is either built-in or
remotely stored in the Repository.
  Built-in: No property data stored
centrally.
  Repository: Select the Repository file where
properties are stored. The following fields are pre-filled in using fetched
data
Use a static method Select this check box to invoke a static method in .NET and this will
disable Use an existing instance check box.
Propagate a data to output Select this check box to propagate a transformed data to output.
Use an existing instance Select this check box to reuse an existing instance of a .NET object from
the Existing instance to use list.

Existing instance to use: Select an
existing instance of .NET objects created by the other .NET components from the
list.

Note: This check box will be disabled if you have
selected Use a static method and
selecting this check box will disable Dll to
load
, Fully qualified class
name(i.e. ClassLibrary1.NameSpace2.Class1)
and Value(s) to pass to the
constructor
.
Dll to load Type in the path, or browse to the DLL library containing the class(es) of
interest or enter the assembly’s name to be used. For example, System.Data, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
for an OleDb assembly.
 Fully qualified class name(i.e.
ClassLibrary1.NameSpace2.Class1)
Enter a fully qualified name for the class of interest.
Method name Fill this field with the name of the method to be invoked in .NET.
Value(s) to pass to the constructor Click the plus button to add one or more lines for values to be passed to
the constructor for the object. Or, leave this table empty to call a default
constructor for the object.

The valid value(s) should be the
parameters required by the class to be used.

Method Parameters Click the plus button to add one or more lines for parameters to be passed
to the method.
Output value target column Select a column in the output row from the list to put value into
it.

Advanced settings

Create a new instance at each row Select this check box to create a new instance at each row that passes
through the component.
Method doesn’t return a value Select this check box to invoke a method without returning a value as a
result of the processing.
Returns an instance of a .NET Object Select this check box to return an instance of a .NET object as a result of
a invoked method.
Store the returned value for later use Select this check box to store the returned value of a method for later
reuse in another tDotNETRow
component.
tStatCatcher Statistics Select this check box to collect log data at the component level.

Global Variables

Global Variables

NB_LINE: the number of rows processed. This is an After
variable and it returns an integer.

ERROR_MESSAGE: the error message generated by the
component when an error occurs. This is an After variable and it returns a string. This
variable functions only if the Die on error check box is
cleared, if the component has this check box.

A Flow variable functions during the execution of a component while an After variable
functions after the execution of the component.

To fill up a field or expression with a variable, press Ctrl +
Space
to access the variable list and choose the variable to use from it.

For further information about variables, see
Talend Studio

User Guide.

Usage

Usage rule This component is utilized to integrate with .NET objects.

To use this component, you must first install the runtime DLLs,
for example janet-win32.dll for Windows 32-bit version
and janet-win64.dll for Windows 64-bit version, from the
corresponding Microsoft Visual C++ Redistributable Package. This allows you to
avoid errors like the UnsatisfiedLinkError on dependent
DLL.

So ensure that the runtime and all of the other
DLLs which the DLL to be called depends on are installed and their versions are
consistent among one another.

Note:

The required DLLs can be installed in the System32 folder or in the bin folder of the
Java runtime to be used. If you need to export a Job using this component to
run it outside the Studio, you have to specify the runtime container of
interest by setting the -Djava.library.path argument
accordingly. For users of
Talend
solutions with ESB, to run a Job using this component in ESB
Runtime, you need to copy the runtime DLLs to the %KARAF_HOME%/lib/wrapper/ directory.

Integrating .Net into Talend Studio: Introduction

This article describes the way to integrate .Net into Talend Studio, for example,
invoking dll methods in a Talend Studio Job.

Based on the runtime dlls (such as janet-win64.dll), Talend Studio provides the
capability of integrating .NET and Java, through which you can access C++ libraries and
invoke their methods easily in Java. Normally, for a Talend Studio user, this can be
implemented in two ways: utilizing the components in the DotNET family (that is,
tDotNetInstantiate and tDotNetRow) in Talend Studio and custom code. This article
discusses the first method.

In a Talend Studio Job, the tDotNetInstantiate component can be used as a start component
in a flow or an independent subJob. It loads a system assembly or a custom dll by
creating a .NET object. The object can then be used by the subsequent tDotNetRow
components for invoking the methods. You need also to specify the class and set
parameters of the constructor for a tDotNetInstantiate component.

The tDotNetRow component references a .NET object created by a tDotNetInstantiate
component. It can be used mid-flow, start the flow, or end the flow. You need to specify
the method to be invoked and set the parameters for the method. This component also
passes the output of the method to a specified column defined in the schema. So, you
need to add columns in the schema of the component and specify the column which the
output values are passed to.

Note: For information about configuring the tDotNetInstantiate and tDotNetRow components,
see Talend Components Reference Guide.

This article shows the way to invoke dll methods in a Talend Studio Job, which uses the two DotNet family
components.

Integrating .Net into Talend Studio: Prerequisites

The prerequisites for invoking dll methods in a Talend Studio Job:

  • Obtain the janet dll (that is, janet-win64>.dll): click here for .NET 3.5 or here for .NET 4.0.
  • Place the file in a directory that the system variable Path
    points to (for example, %JAVA_HOME%in,
    C:WindowsSystem32, etc). You can also place it in another
    directory. In this case, you need to add the directory as a library path using
    -Djava.library.path=path_to_directory_containing_the_dll.
  • The system assembly or the dll to integrate already exists.

Integrating .Net into Talend Studio: configuring the Job

Configuring tDotNetInstantiate

In the Basic settings of the tDotNetInstantiate component,
take the following steps.

  1. Specifying the dll to load in the DDL to load field. The
    DLL can be a system assembly or a custom DLL.

    tDotNETRow_1.png

    For system assemblies, you can specify the name of the desired system
    assembly (for example, “System.Data, Version=2.0.0.0,
    Culture=neutral, PublicKeyToken=b77a5c561934e089”)
    ; for custom
    dlls, you need to provide the absolute path to the dll (for example,
    "C:\WINDOWS\system32\ClassLibrary1.dll)".

  2. Specify the class name and the name space in the Fully qualified
    class name
    field
  3. Set parameter values for the constructor in the Value(s) to pass to the constructor field.

Configuring tDotNetRow

The tDotNetRow component invokes methods of a .Net object created by a
tDotNetInstantiate component and passes the output (if any) to the next component.
This component can also create .Net objects, which can also be reused by subsequent
components.

In the Basic settings of the tDotNetRow component, take the
following steps.

  1. Add columns in the schema by clicking the Edit schema
    button or using the schema propagated to this component. You need to specify one
    of the columns of the schema for holding the output value (if any) using the
    Output value target column drop-down list.

    tDotNETRow_2.png

  2. Select Propagate data to output to pass the data from
    input to output.
  3. Take either of the following two options.

    • If you have deployed a tDotNetInstantiate component for creating the
      .Net object, select Use an existing instance and
      select the component from the Existing instance to
      use
      drop-down list to refer the corresponding .Net
      object.
    • You can also create a new .Net object for use. To achieve this, make
      sure Use an existing instance is not select, set
      DLL to load, Fully qualified class
      name
      , Method Name, and
      Value(s) to pass to the constructor options
      as needed.
  4. Provide the name of the method to invoke in the Method
    Name
    field.
  5. Provide the parameter values for the method in rows of the Method
    Parameters
    filed. As prompted, you can use input row values as
    parameter values (for example, input_row.column_name).

    Note:

    • For information about other options of this component, refer to
      Talend Components Reference Guide.
    • See Utilizing .NET in Talend section in Talend Components Reference
      Guide
      for an example of this article.

Utilizing .NET in Talend

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.

tDotNETRow_3.png

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:

    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.

    tDotNETRow_4.png

  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.

    tDotNETRow_5.png

  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.

    tDotNETRow_6.png

    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.

    tDotNETRow_7.png

  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.

tDotNETRow_8.png

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


Document get from Talend https://help.talend.com
Thank you for watching.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x