Scenario: Printing out the content of a global variable - 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 is a simple Job that prints out the value of a global variable defined in the tSetGlobalVar component.

Setting up the Job

  1. Drop the following components from the Palette onto the design workspace: tSetGlobalVar and tJava.

  2. Connect the tSetGlobalVar component to the tJava component using a Trigger > OnSubjobOk connection.

Configuring the tSetGlobalVar component

  1. Double-click the tSetGlobalVar component to display its Basic settings view.

  2. Click the plus button to add a line in the Variables table, and fill the Key and Value fields with K1 and 20 respectively.

  3. Then double-click the tJava component to display its Basic settings view.

  4. In the Code area, type in the following lines:

    String foo = "bar";
    String K1;
    String Result = "The value is:";
    
    Result = Result + globalMap.get("K1");
    
    System.out.println(Result);
    
    

    In this use case, we use the Result variable. To access the global variable list, press Ctrl + Space bar on your keyboard and select the relevant global parameter.

Job execution

Save your Job and press F6 to execute it.

The content of global variable K1 is displayed on the console.