August 17, 2023

tMongoDBRow – Docs for ESB 5.x

tMongoDBRow

tMongoDBRow_icon32_white.png

Warning

This component will be available in the Palette of
Talend Studio on the condition that you have subscribed to one of
the Talend
solutions with Big Data.

tMongoDBRow Properties

Component family

Big Data / MongoDB

 

Function

tMongoDBRow executes the commands
and functions provided by the MongoDB database.

Purpose

This component allows you to execute the commands and functions of
the MongoDB database.

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 encrypted connection.

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

For further information about tSetKeystore, see tSetKeystore.

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.

 

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.

 

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
stored remotely in the Repository.

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.

 

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

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

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

Log4j

The activity of this component can be logged using the log4j feature. For more information on this feature, see Talend Studio User
Guide
.

For more information on the log4j logging levels, see the Apache documentation at http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Level.html.

Limitation

n/a

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

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.

    use_case_tmongodbrow_1.png

Configuring the components

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

    use_case_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.

    use_case_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.

    use_case_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.

    use_case_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 button_copy_all_from_out_to_in.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.

    use_case_tmongodbrow_6.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.

    use_case_tmongodbrow_7.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.

    use_case_tmongodbrow_8.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.

    use_case_tmongodbrow_9.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