如何在 jbpm 组件中传递 Map in camel context

how to pass Map in camel context in jbpm component

看位置JBPMComponentIntegrationTest

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

所以他们的地图在 java 路线中作为地图传递。

如果我想通过 xml 传递同样的信息,有什么办法吗?

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

我在互联网上找不到任何示例。

如果您使用的是 spring 上下文,您可以简单地初始化地图,然后在常量文件中引用它。我不是 100% 熟悉 xml 骆驼结构,但它看起来应该类似于:

<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>