I’m using the camunda-bpm-camel-master modules to have a camel route trigger a camunda process. The camel route watches a drop folder on an ftp site, when a file is detected it is transferred to a local working directory, the contents of the file are read and transformed into a map that is put into the body of the message, then a camunda process is started with the map in the body being used as process variables.
Everything is working fine as to starting the process; however the camel route does not clean up its temporary file(s) in the local working directory.
After investigating the problem, it seems this is related to the original message being lost in the route (at least its headers are gone).
As a matter of fact the camunda StartProcessProducer’s process method does the foloowing at the very end of the method :
…
exchange.setProperty(CAMUNDA_BPM_PROCESS_DEFINITION_ID, instance.getProcessDefinitionId());
exchange.setProperty(CAMUNDA_BPM_PROCESS_INSTANCE_ID, instance.getProcessInstanceId());
exchange.getOut().setBody(instance.getProcessInstanceId());
…
Thsi effectively outputs a completely new message and the camel route continues with this new message (the original message being lost, and hence camel does not know any more that it needs to do a clean up of the local files).
To solve the problem, the code should be changed to (just replace the getOut() by getIn() )
…
exchange.setProperty(CAMUNDA_BPM_PROCESS_DEFINITION_ID, instance.getProcessDefinitionId());
exchange.setProperty(CAMUNDA_BPM_PROCESS_INSTANCE_ID, instance.getProcessInstanceId());
exchange.getIn().setBody(instance.getProcessInstanceId()); // This leaves the headers of the message intact as well as any attachments, the changing of the body does not influence the camel route processing(Guy)
…
Modifying a camel message is also being described at http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html
Can you consider and verify this proposed solution and build it into the camunda-bpm-camel-master distribution?
Kind regards,
Guy