No passing of process variables with camel

hi community,

i still face some struggles concering my process variable camel integration with camunda.

let me explain with this simple process. when a certain file is dropped it should trigger the process. the userTask is actually empty.


according to i added “copyProperties” to my endpoint because i want to have the properties passed to the process engine. i actually want to pass the filename (+path).

from("file://" + SOURCE_FOLDER)
                .setProperty("kunde", xpath("*//Kunde/text()"))
                    .to("file://" + XML_FOLDER)
                    .to("file://" + MOVED_FOLDER)
                .end().process(new Processor() {
            public void process(Exchange exchange) throws Exception {
                exchange.setProperty("testProperty", "testValue");
                System.out.println("Processing file: " + exchange.getProperty("CamelFileExchangeFile"));

(please note that i just picked some random variables. i will insert the filepath later when it works)

i was not sure if the property must be set before the process(Exchange exchange) starts or afterwards therefore i added a property before and after this method which results in the following:

17:20:03,463 INFO  [stdout] (Camel (camel-1) thread #1 - file://X:%5COV%5CBeispieldaten%5CIncome) {} ===============
17:20:03,463 INFO  [stdout] (Camel (camel-1) thread #1 - file://X:%5COV%5CBeispieldaten%5CIncome) {} Processing file: GenericFile[X:\OV\Beispieldaten\Income\Rechnung.xml]
17:20:03,463 INFO  [stdout] (Camel (camel-1) thread #1 - file://X:%5COV%5CBeispieldaten%5CIncome) {} ===============
17:20:03,463 INFO  [stdout] (Camel (camel-1) thread #1 - file://X:%5COV%5CBeispieldaten%5CIncome) {} {CamelBatchSize=1, testProperty=testValue, CamelMessageHistory=[DefaultMessageHistory[routeId=route1, node=convertBodyTo1], DefaultMessageHistory[routeId=route1, node=choice1], DefaultMessageHistory[routeId=route1, node=setProperty1], DefaultMessageHistory[routeId=route1, node=to1], DefaultMessageHistory[routeId=route1, node=to2], DefaultMessageHistory[routeId=route1, node=process1]], CamelBatchComplete=true, CamelExternalRedelivered=false, CamelCreatedTimestamp=Thu Mar 26 17:20:03 CET 2020, CamelFileExchangeFile=GenericFile[X:\OV\Beispieldaten\Income\Rechnung.xml], CamundaBpmProcessInstanceId=a5fabea6-6f7d-11ea-98b4-40b076df2e43, CamundaBpmProcessDefinitionId=Process_ReceivedXML:16:8bcfd4ba-6f7d-11ea-98b4-40b076df2e43, CamelBatchIndex=0, CamelToEndpoint=camunda-bpm://start?amp%3BcopyProperties=&processDefinitionKey=Process_ReceivedXML, kunde=org.apache.xml.dtm.ref.DTMNodeList@312107d3}

so both properties (‘kunde’ and ‘testProperty’) can be retrieved with getProperties(). but when i claim the userTask and click on “load variables” none of my properties are shown, only “camelBody”… i dont get whats wrong?! can someone help me?

nevermind, its working now.

as i need only the filepath to be passed to camunda, i was able to overwrite the camelBody-variable as follows:

.groovy("def camelBody = ('C:\\\\someDir\\\\anotherDir\\\\XML\\\\' + request.headers.get('CamelFileName'))")

i actually tried to set a “test” variable via grooy there, but it put the value to camelBody. therefore i changed the variable name directly to camelBody. i dont think this is meant to be but it is working for me so its fine.