Search code examples
apache-cameljbpm

how to pass Map in camel context in jbpm component


look at the location JBPMComponentIntegrationTest

.setHeader(JBPMConstants.PARAMETERS, constant(map))

so them map is passed as map in java route.

If i want to pass the same via xml is there a way ?

            <camel:setHeader headerName="CamelJBPMParameters">
            <camel:constant>????</camel:constant>
        </camel:setHeader>

I could not find any example over internet.


Solution

  • If you are using a spring context you could simply initialize the map then reference it in your constant file. I am not 100% familiar with the xml camel constructs but it should look similar to this:

    <camelContext id="myContext"  xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="direct:start"/>
                <setHeader headerName="theHeader">
                    <!-- not sure if the ref keyword is valid might have to adjust syntax -->
                    <constant ref="maps" />      
                </setHeader>
                <to uri="mock:result"/>
        </route>
    </camelContext>
    
    <property name="maps">
        <map>
            <entry key="Key 1" value="1" />
            <entry key="Key 2" value="2" />
            <entry key="Key 3" value="3" />
        </map>
    </property>