Hi guys!
I’ve several processes that have 1 or more Call Activities.
All our processes need some “system variables” grouped in a map(i.e.: environment, track id, client_name, etc.).
I would like to build a piece of code to add via code in a ParseListener that adds this map (systemVariables) to the called process in the Call Activity as is shown in the following screenshot.
I know I must implement the parseCallActivity but I didn’t find any documentation that shows how to add that variable.
Do you have some additional documentation/code snippet/recommendation to give me?
Well, I think I found a solution.
Since I need to add the map mentioned in the previous post, I have implemented a Parser Listener base on AbstractBpmnParseListener with the following Override:
@Override
public void parseCallActivity(
Element callActivityElement, ScopeImpl scope, ActivityImpl activity) {
CallableElement element =
((CallActivityBehavior) activity.getActivityBehavior()).getCallableElement();
CallableElementParameter elementParameter = new CallableElementParameter();
elementParameter.setSourceValueProvider(
new ConstantValueProvider("systemVariables"));
elementParameter.setTarget("systemVariables");
elementParameter.setAllVariables(false);
elementParameter.setReadLocal(false);
element.addInput(elementParameter);
super.parseCallActivity(callActivityElement, scope, activity);
}
This solution is working fine for each Call Activity I have in Camunda.
It was very hard to find a solution because I was not able to find any kind of documentation or code snipped related to this need.
If you think you have a better solution, I will appreciate your comments, guys!
Good question!
First, an introduction
Those variables are part of the tracking info for each request we have in our system.
Some of those variables are HTTP headers. So, We build a filter to inject headers as variables.
Those variables are taken automatically by a Java delegate that makes HTTP requests.
Due to the fact it is mandatory to have that tracking info, we think it is a good idea to make it automatically.
And now, answering your question, processes invoked using call activity tasks doesn’t have visibility of parent’s variables. So you need to specify which variable you want to pass to the called process.
Regards,
Diego
Aha! Now the situation is clearer now. The values are not static but rather per request / process instance.
Can’t you then attach a listener to the call activity? The listener would set the system vars as a local variable. As the varable input mapping, youd’d then choose “all” and “local”.