Triggers are used to link the MDM Hub and the Data Models you define in the Studio. You can use Triggers to call specific Processes under certain conditions.
The Triggers you define in Talend Studio enable different services to be undertaken on specific data records.
Then, whenever a business user creates or modifies a data record from Talend MDM Web User Interface, for example, a Trigger kicks in and the relevant event-based Process is undertaken by the Studio.
The section below explains how to create a Trigger from scratch, however, Talend Studio enables you as well to automatically generate Triggers based on the Jobs listed under the Job Designs node in the MDM Repository tree view. You can then do any modifications in the generated Trigger, if required. For further information, see Generating a job-based Trigger.
Triggers are rules for transforming data. You can easily define Triggers on specific business entities/elements from Talend Studio.
Parameters to set when defining Triggers include:
selecting the business entity you want to Trigger the Process on,
setting conditions on its content,
deciding the execution mode,
selecting the service to Trigger,
setting the service parameters.
Prerequisite(s): You have already connected to the MDM server from Talend Studio. You have the appropriate user authorization to create Triggers.
For this example, a data model called Product has been created in Talend Studio. This data model has two business entities: Product and ProductFamily. Several attributes have been created in the Product entity including Price and Family. For further information about how to create a data model, see Setting up a data model.
A Process has been created and named Call_Job. One service has been defined in this Process to launch a validation Job whenever a price of an item that belongs to a specific family has been changed through Talend MDM Web User Interface. For further information about how to create such a Process, see How to create a Process from scratch.
What is left to be done now is to create a Trigger and configure it to launch the Call a Job from MDM Process that will by turn launch the Talend price validation Job.
The sub-sections below explain in detail the procedures necessary to complete the creation of such a Trigger.
To create a Trigger, you must first define the business entities in a selected data model on which you want to trigger a specific Process. You also need to define the execution mode. To do this:
In the MDM Repository tree view, expand Event Management and then right-click Triggers and select New from the contextual menu.
The [New Trigger] dialog box displays.
Enter a name for the new Trigger and then click OK to close the dialog box.
An editor for the newly created Trigger opens in the workspace.
No spaces are allowed in the Trigger name. The OK button in the dialog box will be unavailable as long as there is a space in the instance name.
In the Description field, enter a description to identify the Trigger being created.
In this example, the Trigger will launch a Process that will by turn launch the Job ValidatePriceChange_0.1.
Click the three-dot button next to the Entity field to open a dialog box where you can select the business entity you want to trigger the Process on, Product in this example.
In the open dialog box, click the Data Models arrow and select the data model that holds the business entity you want to run the Trigger on.
Select the business entity in the list and click Add to close the dialog box.
The selected business entity name displays in the Entity field.
Select the check box next to the execution mode you want to use:
immediately executes the triggered Process. In most cases, this implies that an open connection from a source system will not be released until the data record has been pushed to the destination system and the connection is released by the destination system.
Execution Order: enter an integer value (equal to or greater than zero) in this field to specify the order in which this Trigger will be executed if it is among multiple Triggers which are eligible for a given event. The lower the value, the earlier the Trigger will be executed.
Bear in mind the following:
To put the defined Trigger on hold.
After defining the business entity on which you want to trigger a specific Process, you need to select a service to run on the defined business entity and set the service parameters.
To select a service to trigger and set the parameters, do the following:
In the Service area, click the Service JNDI Name arrow and select from the list the service you want to kick off by the Trigger, callprocess in this example.
The services you can find in the list are pre configured MDM services. Click the button to open a dialog box that gives information about what the service does and its parameters.
In the Service Parameters area, define the parameters of the service you select in the list.
When you select the callprocess service, you just need to click the name of the Process you want to trigger, Call_Job in this example. For more information about how to create a Process from scratch, see How to create a Process from scratch.
The callprocess service is one of the most important available services on the list. When you select this service, all Processes you already created in Talend Studio are listed in the Service Parameters area and you can call any of them to transform and cross-reference master data. For more information on Processes, see Processes.
The parameters you need to define in the Service Parameters area differ according to the selected service in the service list. Talend Studio simplifies this task for you by creating the underlying XML code for the proper execution of the trigger.
When you select the callJob service, for example, you can access a list of all deployed Jobs directly from the Trigger editor.
When you select the workflowcontext service, for example, you can access a list of all deployed workflows directly from the Trigger editor and this simplifies the process of creating a Trigger.
In the Service Parameters area, you can specify the Workflow process version number and the user name and password for accessing the BPM server. The specified credentials here will override the default settings for the Bonita technical users in the file <$INSTALLDIR>\conf\mdm.conf where <$INSTALLDIR> specifies the path where the MDM server has been installed. For more information, see the Talend Installation Guide.
For certain services, you can switch between a graphical editor and a text editor upon clicking the Sheet and Source tabs respectively. You can define the service parameters in either editors and any modifications you do in one of the two editors will be reflected in the other.
After selecting a pre-configured service to run on the selected business entity and defining the service parameters, you must set conditions on the content of the selected business entity.
To configure the conditions for this Trigger, do the following:
In the Trigger xPath Expressions area, click the button to add a new XPath line to the table where you can set the first condition.
Click in the new line, and then click the three-dot button to open a dialog box where you can select the entity and/or element on which you want to define conditions, Update/OperationType in this example.
Click in the Operator column and select an operator from the list.
In the Value column, enter a value for each of the selected business entities/elements, the value is usually the name of the entity or element. Enter the UPDATE value in this example (case sensitive).
In the Condition Id column, enter a unique identifier for the condition you want to set on the selected business entity/element, C1 in this example.
This first condition means that the Trigger will be executed only on the records in the Update entity when there is an update operation. You may want to activate this Trigger only if the update operation is done on the Price attribute. So, follow the same steps to define this second condition on the Item/path attribute using the Price value and C2 condition.
In the Conditions area, enter the query you want to undertake on the data record using the condition IDs you set earlier, C1 And C2 in this example.
The Trigger created in the above procedure means that you want the Trigger to be executed on a record in the Update entity only when the Price attribute has been changed.
When the conditions match the content of the data record, the selected service is triggered on the content of the data records that match the set conditions.
Click the save icon on the toolbar or press Ctrl + S on your keyboard to save your changes.
This newly created trigger is listed under the Trigger node in the MDM Repository tree view.
An authorized user can also test, import/export, copy/paste and delete created Triggers from Talend Studio.
It is also possible to import and share MDM complete projects or only a data model or part of the data model from the community web page, Talend Exchange. For further information, see Projects/objects on Talend Exchange.
Talend Studio allows you to test Triggers to see if one or more Triggers which match the test conditions defined by an event record will be executed as expected.
The event record which is used to test Triggers will be processed by the Event Manager. When the conditions defined in the event record correspond to the execution conditions of a Trigger, the Trigger will be executed.
For synchronous Triggers, the execution results will be returned directly. For asynchronous Triggers, you have to check the log of activity on MDM server to figure out the real status of the execution results.
Prerequisite(s): You have already connected to the MDM server. One or more Triggers to be tested have already been deployed to the MDM server.
For further information about Triggers, see Triggers.
To test Triggers in the Studio, do the following:
In the MDM Repository tree view, expand the Event Management and Trigger nodes and then select Test from the contextual menu.
A dialog box opens asking you to select the appropriate server on which the MDM server is installed.
Once you have made your choice, click OK to close the dialog box.
The [Select Record] dialog box opens. The selected server is shown in the Server list.
Select UpdateReport from the Container list.
The UpdateReport document contains all the event records generated whenever a data record is created, updated or deleted. Each time the Event Manager receives a document, it tries to evaluate the conditions of each Trigger against this document.
You need to choose one event record to test Triggers.
Click the icon next to the Entity list to display a list of records.
If required, define conditions in the Record Search area to filter the records to be displayed. For example, you can select a specific time in the From and To fields respectively to display only the records generated during that period of time.
Click the desired record to display its content in the Record Content area.
If needed, you can create a new record to be used for testing Triggers. For more information, see How to create a new record for testing Triggers.
Click Test. A prompt message pops up, showing that one or more Triggers which match the conditions of the selected event record are executed successfully.
To verify the execution results of those Triggers, consult the mdm.log file in one of the following ways:
In the Server Explorer panel, right-click the connection to the server where MDM server is installed, and then click View Server Log. A Console opens displaying the most recent contents of the mdm.log file.
You can also view the contents of the mdm.log file in a browser. For further information about viewing the log of activity on MDM sever, see Viewing the log of activity on the MDM server.
If you have direct access to the MDM server, you can also consult the file directly in the <$INSTALLDIR>/log directory.
Talend Studio allows you to create a new record to be used for testing Triggers if you cannot find the desired record in the listed records. For more information about testing Triggers in the Studio, see How to test Triggers in the Studio.
To create a new record for testing Triggers, do the following:
In the [Select Record] dialog box, right-click in the area where the records are listed and click New Record.
A dialog box opens providing an XML editor and viewer.
Enter a record that defines the conditions to be used to test Triggers. You can also have a tree view of the record by clicking the Tree tab.
In this example, one piece of UpdateReport document is prepared. Note that the Update Reports are stored in Talend MDM as an XML document like any other master data but with a pre-defined, static data model.