Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Stardust/Knowledge Base/Integration/Camel/Camel File based inter-system integration - Camel

< Stardust‎ | Knowledge Base‎ | Integration‎ | Camel
Revision as of 05:23, 29 September 2014 by Vikash.pandey.sungard.com (Talk | contribs) (Created page with "== Overview == In this article we are going to explore, how we can use Stardust Camel Application types to integrate 2 different systems. the medium of communication would be...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Overview

In this article we are going to explore, how we can use Stardust Camel Application types to integrate 2 different systems. the medium of communication would be a Stardust generated CSV file.

The Use Case:

  • User enters details in Stardust portal UI into a stardust process data.
  • Stardust converts the process data into a CSV file and put it into a designated folder (e.g. outbound) on the file system and halts the process execution.
  • The other application (e.g. SAP) picks up the CSV file, after working on it, the other application puts the file in a designated folder (e.g. inbound) for stardust halted process instance to pick it up and continue.
  • Another stardust process instance picks up the file from the designated folder (e.g. inbound), performs some logic to identify which CSV file belongs to which halting process instance (of step 1) and sends a message to that instance to resume its operations further.
  • The resuming process instance then consumes the CSV file and converts its content into a stardust process data for further use.

Approach

To implement the use case we will be: Defining 2 processes (1 which will do the processing like, convert process data into CSV, halting, resuming and converting CSV back into process data and another which will monitor the designated folder where the other application (e.g. SAP) is going to write the processed CSV file.

1st process will have 3 activities (2 interactive and 1 application that will use stardust Camel application type)

The Camel application activity will configure Camel routes to convert process data into CSV, putting it to a designated folder from there the other application (e.g. SAP) will consume the file and to go into hibernation.

2nd process will use Camel application type to monitor the designated folder where the other integrating application will write the processed CSV and will apply some logic to create a message to send to hibernating process instance of the 1st process.

1st process, lets name it as Order Entry Process: 2nd process, lets name it as CSV Consumer Process

How To Do

For this example we are considering outbound as a folder where stardust will write converted CSV file and inbound as a folder where integrating application will write back processed CSV file and inbound is the folder that will monitored by CSV Consumer Process's camel application.

  • Defining Order Entry Process


The route of the Convert Order To CSV application explained:

  • Producer part:
<setHeader headerName="CamelFileName">
<simple>${header.ippActivityInstanceOid}_Order.csv</simple>
</setHeader>
<to uri="file://c:\temp\outbound"/>
  • Consumer part (this is responsible to make process instance getting into hibernated mode)
<from uri="direct:csvTempQueue"/>
<to uri="ipp:authenticate:setCurrent?user=motu&password=motu" />
<setHeader headerName="CamelLanguageScript">
<constant>
function setOutHeader(key, output){
request.setHeader(key, output);
}
var line= request.headers.get("ActivityOID");
//var part = line.split("_");
setOutHeader("ActOID", parseInt(line));
</constant>
</setHeader>
<to uri="language:javascript?transform=false"/>
 
<to uri="ipp:activity:find?expectedResultSize=-1&activityInstanceOid=$simple{header.ActOID}&states=Application,Created,Hibernated,Interrupted,Suspended" />
<convertBodyTo type="java.lang.String"/>
<to uri="ipp:activity:complete" />
  • Defining CSV Consumer Process

The route of the consumer process application "Consume CSV File":

<from  uri="file://c:\temp\inbound?delete=false&consumer.initialDelay=2000&include=.*csv$"/>
<setHeader headerName="CamelLanguageScript">
<constant>
function setOutHeader(key, output){
request.setHeader(key, output);
}
var fileName = request.getHeader("CamelFileName");
var actOID = fileName.split("_");
 
setOutHeader("ActivityOID", parseInt(actOID[0]));
</constant>
</setHeader>
<to uri="language:javascript?transform=false"/>
<to uri="direct:csvTempQueue"/>

Execution

Artifacts

Back to the top