138.7. velocity Context
Camel 将在 Velocity 上下文中提供交换信息(忽略 映射)。Exchange 被传输为:
| key | value |
|---|---|
|
|
|
|
|
|
|
| In 消息的标头。 |
|
| Camel 上下文实例。 |
|
| In 消息。 |
|
| In 消息。 |
|
| In 消息正文。 |
|
| Out 消息(仅适用于 InOut 消息交换模式)。 |
|
| Out 消息(仅适用于 InOut 消息交换模式)。 |
您可以通过设置属性 allowTemplateFromHeader=true 并设置消息标头 CamelVelocityContext 来设置自定义 Velocity Context,如下所示
VelocityContext velocityContext = new VelocityContext(variableMap);
exchange.getIn().setHeader("CamelVelocityContext", velocityContext);
VelocityContext velocityContext = new VelocityContext(variableMap);
exchange.getIn().setHeader("CamelVelocityContext", velocityContext);