July 30, 2023

tMongoDBRow – Docs for ESB 7.x

tMongoDBRow

Executes the commands and functions of the MongoDB database.

tMongoDBRow Standard properties

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

The Standard
tMongoDBRow component belongs to the Big Data and the Databases NoSQL families.

The component in this framework is available in all Talend products with Big Data
and in Talend Data Fabric.

Basic settings

Use existing connection

Select this check box and in the Component List click the relevant connection component to
reuse the connection details you already defined.

DB Version

List of the database versions.

Available when the Use existing
connection
check box is not selected.

Use replica set address

Select this check box to show the Replica
address
table.

In the Replica address table, you can
define multiple MongoDB database servers for failover.

Available when the Use existing
connection
check box is not selected.

Server and Port

Address and listening port of the database server.

Available when the Use existing
connection
or Use replica set
address
check box is not selected.

Database

Name of the database.

Use SSL connection

Select this check box to enable the SSL or TLS encrypted connection.

Then you need to use the tSetKeystore
component in the same Job to specify the encryption information.

Note that the SSL connection is available only for the version 2.4 + of
MongoDB.

Required authentication

Select this check box to enable the database authentication.

Among the mechanisms listed on the Authentication mechanism
drop-down list, the NEGOTIATE one is recommended if
you are not using Kerberos, because it automatically select the authentication mechanism
the most adapted to the MongoDB version you are using.

For details about the other mechanisms in this list, see MongoDB Authentication from the MongoDB
documentation.

Set Authentication database

If the username to be used to connect to MongoDB has been created in a specific
Authentication database of MongoDB, select this check box to enter the name of this
Authentication database in the Authentication database
field that is displayed.

For further information about the MongoDB Authentication database, see User Authentication database.

Username and Password

DB user authentication data.

To enter the password, click the […] button next to the
password field, and then in the pop-up dialog box enter the password between double quotes
and click OK to save the settings.

Available when the Required
authentication
check box is selected.

If the security system you have selected from the Authentication mechanism drop-down list is Kerberos, you need to
enter the User principal, the Realm and the KDC
server
fields instead of the Username and the Password
fields.

Schema and Edit
Schema

A schema is a row description. It defines the number of fields
(columns) to be processed and passed on to the next component. When you create a Spark
Job, avoid the reserved word line when naming the
fields.

Click Edit
schema
to make changes to the schema. If the current schema is of the Repository type, three options are available:

  • View schema: choose this
    option to view the schema only.

  • Change to built-in property:
    choose this option to change the schema to Built-in for local changes.

  • Update repository connection:
    choose this option to change the schema stored in the repository and decide whether
    to propagate the changes to all the Jobs upon completion. If you just want to
    propagate the changes to the current Job, you can select No upon completion and choose this schema metadata
    again in the Repository Content
    window.

Click Sync
columns
to retrieve the schema from the previous component connected in the
Job.

Execute command

Select this check box to enter MongoDB commands in the Command field for execution.

  • Command: in this field,
    enter the command to be executed, if this command contains
    one single variable.

    For example, if you need to construct the
    command You
    need simply enter isMaster within quotation marks.
  • Construct command from keys and
    values
    : if the command to be executed
    contains multiple variables, select this check box and in
    the Command keys and values
    table, add the variables and their respective values to be
    used.

    For example, if you need to construct the following
    command
    You
    need to add three rows to the Command
    keys and values
    table and enter one
    variable-value pair to each row within quotation
    marks:
  • Construct command from a JSON
    string
    : if you want to directly enter the
    command to be used, select this check box and enter this
    command in the JSON string
    command
    field that is displayed. Only one
    command is allowed per tMongoDBRow.

    For
    example:

    Note that you must use single quotation marks to surround
    the string values used in the command and double quotation
    marks to surround the command itself.

    For further information about the MongoDB commands you can
    use in this field, see https://docs.mongodb.org/manual/reference/command/.

Function

Enter MongoDB functions in the Function field for execution.

Not available when the Execute
command
check box is selected.

Parameters value

Click the [+] button to add lines as
needed and then define the parameter values in the form of variables or
constant values, for example row1.author or “Andy”. Note that the parameter values correspond to the
parameters defined in the Function
field, in the same order.

Not available when the Execute
command
check box is selected.

Die on error

This check box is cleared by default, meaning to skip the row on error
and to complete the process for error-free rows.

Advanced settings

tStatCatcher Statistics

Select this check box to collect the log data at the component
level.

Global Variables

Global Variables

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

tMongoDBRow allows you to manipulate
the MongoDB database through the MongoDB commands and functions.

Using MongoDB functions to create a collection and write data to
it

This scenario applies only to Talend products with Big Data.

This scenario creates the collection blog and writes post
data to it through the MongoDB functions.

Linking the components

  1. Drop tMongoDBConnection, tFixedFlowInput, tMongoDBRow, tMongoDBClose,
    tMongoDBInput and tLogRow onto the workspace.
  2. Rename tFixedFlowInput as blog_post_data, tMongoDBRow as write_data_to_collection, tMongoDBInput as read_data_from_collection and tLogRow as show_data_from_collection.
  3. Link tMongoDBConnection to tFixedFlowInput using the OnSubjobOk trigger.
  4. Link tFixedFlowInput to tMongoDBRow using a Row > Main
    connection.
  5. Link tFixedFlowInput to tMongoDBInput using the OnSubjobOk trigger.
  6. Link tMongoDBInput to tMongoDBClose using the OnSubjobOk trigger.
  7. Link tMongoDBInput to tLogRow using a Row > Main
    connection.

    tMongoDBRow_1.png

Configuring the components

  1. Double-click tMongoDBConnection to open
    its Basic settings view.

    tMongoDBRow_2.png

  2. From the DB Version list, select the
    MongoDB version you are using.
  3. In the Server and Port fields, enter the connection details.

    In the Database field, enter the name of the MongoDB
    database.
  4. Double-click tFixedFlowInput to open its
    Basic settings view.

    tMongoDBRow_3.png

    Select Use Inline Content (delimited
    file)
    in the Mode
    area.
    In the Content field, enter the data to write to the
    MongoDB database, for example:
  5. Double-click tMongoDBRow to open its
    Basic settings view.

    tMongoDBRow_4.png

    Select the Use existing connection check
    box.
    In the Function field, enter the MongoDB function to
    create the collection blog and insert
    data to it:
  6. Click the […] button next to Edit schema to open the schema editor.

    tMongoDBRow_5.png

  7. Click the [+] button to add four columns
    in the right part, namely author,
    title, keywords and contents,
    with the type of String.

    Click

    tMongoDBRow_6.png

    to copy all the columns to the input table.

    Click OK to close the editor.
  8. In the Parameters value table, click the
    [+] button to add four lines and enter
    the values in sequence: row1.author,
    row1.title, row1.keywords and row1.contents. By doing so, data of row1 will be transferred to the parameters defined in the
    function.
  9. Double-click tMongoDBInput to open its
    Basic settings view.

    tMongoDBRow_7.png

    Select the Use existing connection check
    box.
    In the Collection field, enter the name
    of the collection, namely blog.
  10. Click the […] button next to Edit schema to open the schema editor.

    tMongoDBRow_8.png

  11. Click the [+] button to add four columns,
    namely author, title, keywords and
    contents, with the type as String.

    Click OK to close the editor.
  12. Double-click tLogRow to open its
    Basic settings view.

    tMongoDBRow_9.png

    In the Mode area, select Table (print values in cells of a table for
    better display.

Executing the Job

  1. Press Ctrl+S to save the Job.
  2. Press F6 to run the Job.

    tMongoDBRow_10.png


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