Reader small image

You're reading from  Getting Started with Talend Open Studio for Data Integration

Product typeBook
Published inNov 2012
Reading LevelIntermediate
PublisherPackt
ISBN-139781849514729
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Jonathan Bowen
Jonathan Bowen
author image
Jonathan Bowen

Jonathan Bowen is an E-commerce and Retail Systems Consultant and has worked in and around the retail industry for the past 20 years. His early career was in retail operations, then in the late 1990s he switched to the back office and has been integrating and implementing retail systems ever since. Since 2006, he has worked for one of the UKs largest e-commerce platform vendors as Head of Projects and, later, Head of Product Strategy. In that time he has worked on over 30 major e-commerce implementations. Outside of work, Jonathan, like many parents, has a busy schedule of sporting events, music lessons, and parties to take his kids to, and any downtime is often spent catching up with the latest tech news or trying to record electronic music in his home studio. You can get in touch with Jonathan at his website: www.learnintegration.com.
Read more about Jonathan Bowen

Right arrow

Chapter 9. Global Variables and Contexts

In any kind of programming, variables are simply placeholders for values that are used in the execution of a program. The values in the variables might change on different executions. For example, the day_of_week variable might hold the value of Tuesday today, but Wednesday tomorrow. Variable values might also change within a single execution. For example, we might use a variable to hold the running total of invoices processed. As each invoice is processed, the value held in the variable will change.

The use of variables allows our jobs to be dynamic and not have hardcoded values in them.

In this chapter, we will learn about:

  • Studio global variables: The variables that the Studio makes available through the components we use in our integration jobs

  • User defined global variables: Ad-hoc variables that can be configured in your jobs

  • Job contexts: The variables we can create to execute jobs with different parameters for different environments or scenarios...

Global variables


We have seen the use of global variables in some of the job examples covered in earlier chapters of the book, but this section will deal with the subject in more detail, showing how we can use the component global variables generated automatically by the Studio. For the more adventurous or experienced developer, we will also explore how to create and use your own global variables.

Studio global variables

Global variables, in the Studio context, are variables that are available to all components, modules, or functions within a job. As we develop jobs in the Studio, global variables are made available depending upon the components used. Let's illustrate this with a simple job.

  1. Import the job named GlobalVariables from the resource directory of this chapter and click through the various components in it. The job contains a file list, delimited input, tMap, and delimited output components. Note that not all of the parameters are configured at this point. We'll address this as...

Contexts


The Studio commonly utilizes another type of variable – a context variable. Context variables allow jobs to be executed in different ways, with different parameters.

A classic example of this is when we develop a job and want to run it in different environments – development, test, and production, for example. Let us suppose that our job has to connect to a database, and, as is common, the connection details for development, test, and production databases are different. We could create three copies of the job, each one with different connection details configured, but this duplicates code and makes job maintenance more difficult. Far better would be to create a single job and allow it to run with different connection details depending upon the database you want to target at any given time. The Studio context solves this problem.

Contexts are user-defined variables that can be invoked at runtime and there are three ways that we can implement context variables – embedded variables,...

Summary


As you become more experienced with the Studio, you will find that you see more and more opportunities to use context variables. Grab these opportunities with both hands! We have explored contexts by using the traditional "test/production" scenario, but it equally exists for "client A/client B/client C", "subsidiary A/subsidiary B/subsidiary C", and many other situations. Contexts make your jobs more flexible and allow you to reuse jobs repeatedly, with only minor changes reflected in context variables.

Our next chapter, Chapter 10, Worked Examples, will take what we have learnt from chapters 3 to 9 and put it all together in some real-life examples of integration jobs. The jobs are more complex and end-to-end in nature and will show how the Studio can manage the full integration process for you.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Getting Started with Talend Open Studio for Data Integration
Published in: Nov 2012Publisher: PacktISBN-13: 9781849514729
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Jonathan Bowen

Jonathan Bowen is an E-commerce and Retail Systems Consultant and has worked in and around the retail industry for the past 20 years. His early career was in retail operations, then in the late 1990s he switched to the back office and has been integrating and implementing retail systems ever since. Since 2006, he has worked for one of the UKs largest e-commerce platform vendors as Head of Projects and, later, Head of Product Strategy. In that time he has worked on over 30 major e-commerce implementations. Outside of work, Jonathan, like many parents, has a busy schedule of sporting events, music lessons, and parties to take his kids to, and any downtime is often spent catching up with the latest tech news or trying to record electronic music in his home studio. You can get in touch with Jonathan at his website: www.learnintegration.com.
Read more about Jonathan Bowen