Technical Articles
Share Data Across Two Integration Flows with Data Store and Variables in CPI
The following example integration flows use a global variable to share data:
-
Integration Flow 1 – Write Variable
This integration flow is initiated by a timer. It connects to an external WebShop and reads data from there to store it on the tenant database (as Data Store entry). The data comprises the list of available products at the time when the integration is operated.
This integration flow also stores the actual timestamp as variable.
-
Integration Flow 2 – Read Variable
This integration flow is also initiated by a timer and runs independently from the first one. It reads the product data (provided by the first integration flow) from the tenant database.
This integration flow also reads the timestamp associated with the latest execution of the first integration flow.
Design Integration Flow 1 – Write Variable
Design integration flow Integration Flow 1 - Write Variable
as depicted in the following figure:
-
The Request Reply step
Request product data from WebShop
connects through the OData channel to the WebShop component and reads product data for all products in the product catalog.Configure the OData adapter in the following way:
In the
Connection
tab, specify the following value for theAddress
parameter:https://refapp-espm-ui-cf.cfapps.eu10.hana.ondemand.com/espm-cloud-web/espm.svc/
The external data source supports the Open DataProtocol (OData). For our scenario, we use the ESPM WebShop, which is based on the Enterprise Sales and Procurement Model (ESPM) provided by SAP. The demo application can be accessed at the following address: https://refapp-espm-ui-cf.cfapps.eu10.hana.ondemand.com/webshop/index.html
In tab
Processing
, specify the following parameters:Parameter Value Operation Details Query (GET) Resource Path Products Query Options $select=ProductId,Price,CurrencyCode,Name This OData request reads product details (ProductID, Price, CurrencyCode, and Name) from the WebShop application.
-
Configure the Write Variables step
Store timestamp
in the following way.-
In field
Name
, enterTimestamp
. -
For parameter
Type
, selectExpression
. -
For parameter
Data Type
, enterjava.lang.String
. -
For parameter
Value
, enter${date:now:yyyy-MM-dd HH:mm:ss}
. -
Select the parameter
Global Scope
in order to share the variable with other integration flows on the same tenant.
Using this expression, the Write Variables step stores the actual timestamp as global variable.
-
-
Configure the Data Store Write step
Write product data into data store
in the following way.-
For
Data Store Name
enterProductCatalog
. -
Don’t enter any value for parameter
Entry ID
.
This step stores the response from the WebShop (which contains the list of all products) as Data Store entry (as entry ID a guid is generated).
You need to deploy this integration first (before deploying the second one).
-
Design Integration Flow 2 – Read Variable
Design integration flow Integration Flow 2 - Read Variable
as depicted in the following figure:
This integration flow is also started by a Timer start event. It reads a product list from the Data Store (that has been updated by the first integration flow) and consumes the timestamp from the first integration flow. It then sends the message content (including the timestamp) to an email receiver.
-
Configure the Data Store Select step
Select from data store
in the following way.-
For
Data Store Name
enterProductCatalog
. -
For parameter
Visibility
, selectGlobal
.
This step reads the entry of the
ProductCatalog
Data Store that has been created by integration flowIntegration Flow 1 – Write Variable
. This entry contains the product catalog content read from the WebShop during the recent message processing run of first integration flowIntegration Flow 1 – Write Variable
. -
-
Configure the Content Modifier
Create property for payload and timestamp
with the following parameters:In tab
Exchange Property
, add the following properties:-
A property containing the payload of the message (which is the content read from the ProductCatalog Data Store entry).
As
Type
, selectExpression
, and in fieldValue
enter${in.body}
. -
A property containing the timestamp for the latest message processing run of integration flow
Integration Flow 1 – Write Variable
. This property is defined by selecting the global variable set by the other integration flow.As
Type
, selectGlobal Variable
, and in fieldValue
enterTimestamp
.This property is defined based on the global variable written by the first integration flow.
-
-
Configure the Content Modifier
Define message body
so that it defines the message body using the following expression:Prices have been updated at ${property.timestamp}; ${property.payload}
Configure the Mail receiver adapter so that it sends the message to an email account of your choice.
The received email tells the user the time when the ProductCatalog
Data Store entry has been updated the latest and provide the content of the product catalog (XML structure).
In this case, I will take the QQ mail as an example.
-
-
Get Authorization Code
Guide: http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=28&&no=1001256
lsheoxnscbawbcbd
-
-
-
Create User Credential in CPI with the Authorization Code got in the last step
-
-
-
Do SMTP Connectivity Tests and download the server certificate chain
-
-
-
Upload Certificate to CPI
-
-
-
Do SMTP Connectivity Tests again with certificate verification
-
-
-
Configure Mail connection
In the
Connection
tab:
-
In the Processing
tab:
Deploy Integration Flows
1. Integration Flow 1 - Write Variable
Check the Data Store in the Data Store
tile:
2. Deploy the integration flow Integration Flow 2 - Read Variable
Check the response in mail box: