2014-10-02 5 views
0

Я пытаюсь установить переменную внутри моего кода верблюда, чтобы я мог вызвать эту переменную, когда я регистрирую свое выполнение маршрута. Эта переменная должна быть установлена ​​из инструкции xpath.Нужна помощь в настройке переменной в Camel

Ниже приведен код, который не работает, и я подозреваю, что мне нужно установить переменную, равную моей инструкции xpath, которая находится в сообщении журнала, но я не знаю, как это сделать.

<?xml version="1.0" encoding="UTF-8"?> 
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:camel="http://camel.apache.org/schema/blueprint" 
     xsi:schemaLocation=" 
     http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd 
     http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd"> 
<bean id="activemq" 
     class="org.apache.activemq.camel.component.ActiveMQComponent"> 
     <property name="brokerURL" value="tcp://localhost:61616"/> 
     <property name="userName" value="user"/> 
     <property name="password" value="password"/> 
</bean> 



    <camelContext id="blueprintContext" trace="false" xmlns="http://camel.apache.org/schema/blueprint"> 
    <route id="Test_Message_Content_Route"> 
     <from uri="activemq:queue:FirstQueue?username=user&amp;password=password&amp;concurrentConsumers=1&amp;maxConcurrentConsumers=5"/> 
     <choice> 
     <when> 
       <xpath>//destination[text()='TEST']</xpath> 
       <log message="Test route invoked"/> 
         <split> 
           <xpath resultType="java.lang.String">//message_payload/text()</xpath> 
           <log message="Routed $xpath{//id/text()} to TEST QUEUE"/> 
           <to uri="activemq:queue:TestQueue?username=user&amp;password=password"/> 
         </split> 
     </when> 
     <when> 
       <xpath>//destination[text()='DEV']</xpath> 
       <log message="Dev route invoked"/> 
         <split> 
           <xpath resultType="java.lang.String">//message_payload/text()</xpath> 
           <log message="Routed $xpath{//id/text()} to DEV QUEUE"/> 
           <to uri="activemq:queue:DevQueue?username=user&amp;password=password"/> 
         </split> 
     </when> 
     <otherwise> 
       <log message="Sending message to DL Queue"/> 
       <to uri="activemq:queue:DLQueue?username=user&amp;password=password"/> 
     </otherwise> 
     </choice> 
    </route> 
    </camelContext> 

</blueprint> 

ответ

1

Я теперь эту работу, используя SetHeader в моем контексте верблюда, как следующее: <setHeader headerName="id"><xpath>//id/text()</xpath></setHeader> <log message="Routed ${header.id} to Test queue"/>

Смежные вопросы