Camel to camunda routes (Using ftp drop folder to trigger Camunda process)

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

Hi Guy.

Sorry for the delay! Thank Phillip who pointed me to this post yesterday evening :slight_smile: The exaplanation you give sounds very reasonable and I don’t see any problem in doing the change you propose. I created https://github.com/camunda/camunda-bpm-camel/issues/29. Would it be possible that you provide a pull requrest via GitHub for it?

I currently have an item on my todo list to review and merge https://github.com/camunda/camunda-bpm-camel/pull/24 - I could do that in one go and release a new version of the component afterwards. But not sure when exactly I will have time for it - hopefully later this month!

Cheers
Bernd