@Michal_S here is a script for you to test.
I have not tested against the timeouts of the executor to see what is actually is occurring, but from a cockpit perspective is looks like its running outside of the executor:
So look at this:
I run the following javascript:
with (new JavaImporter(org.apache.commons.exec)) {
var myString = 'echo "hello Steve!" && sleep 15s && curl --request POST --url http://localhost:8080/engine-rest/message --header "Accept: application/json" --header "Content-Type: application/json" --data \'{"messageName":"myMessage"}\' && echo "hello Stephen!"'
var shellCommand = new CommandLine("sh").addArgument("-c")
shellCommand.addArgument(myString, false)
var resultHandler = new DefaultExecuteResultHandler()
var watchdog = new ExecuteWatchdog(5 * 60000)
var executor = new DefaultExecutor()
executor.setExitValue(1)
executor.setWatchdog(watchdog)
executor.execute(shellCommand, resultHandler)
}
Output would be something like this:
camunda_1 | hello Steve!
… 15 seconds later…
camunda_1 | % Total % Received % Xferd Average Speed Time Time Time Current
camunda_1 | Dload Upload Total Spent Left Speed
100 27 0 0 100 27 0 393 --:--:-- --:--:-- --:--:-- 397
camunda_1 | hello Stephen!
In this scenario above, curl output and the hello Stephen!
echo is from the script that executed in the “Run Shell” task, but it occurred while the engine was at the “Get Background” task.
What appears to happen is the background job is created outside of the Camunda Executor.
and then we run the Localhost:8080 curl to message back to the engine.
I also installed curl on the camunda server to run the command in the sh script.
Would be interested to hear from @camunda / @thorben about some likely issues with doing this ;).
Note:
The script was based on: java - execute shell command with org.apache.commons.exec.DefaultExecutor - Stack Overflow