Issue with Camel Velocity Component Output where headers are cleaned out after processing

Solution Verified - Updated -

Issue

  • Facing an issue in using Camel Velocity component where all the existing headers are cleaned out once exchange is processed by Velocity component.
  • Sequence Workflow is below
    • Accept a file over file endpoint (E:\In) and send to a JMS queue for further processing..
    • From JMS queue, call xslt component (available in E:\XSLT) to do transformation and then hand over to velocity component (available in E:\XSLT) to create a wrapper response.
    • Finally write the response from velocity to a file (E:Out).
<camelContext id="xslt-velocity-test-adaptor" xmlns="http://camel.apache.org/schema/spring">
        <route id="File_JMS" startupOrder="1" autoStartup="true" streamCache="true">
            <from uri="file:///E:/In"/>
            <to uri="activemqLocal:queue:TEST.IN"/>
        </route>

        <route id="JMS_File" startupOrder="2" autoStartup="true" streamCache="true">
            <from uri="activemqLocal:queue:TEST.IN"/>
            <convertBodyTo type="java.lang.String" charset="UTF-8"/>
            <to uri="activemqLocal:queue:TEST.TEMP"/>
            <to uri="direct:xsltProcessor"/>
            <to uri="direct:fileOut"/>
        </route>

        <route id="xslt_processor" startupOrder="3" autoStartup="true" streamCache="true">
            <from uri="direct:xsltProcessor"/>
            <doTry>
                <to uri="activemqLocal:queue:TEST.TEMP"/>               
                <to uri="xslt:file:///E:/XSLT/test.xsl?allowStAX=false"/>
                <to uri="activemqLocal:queue:TEST.TEMP"/>
                <to uri="velocity:file:///E:/XSLT/test.vm"/>                    
                <doCatch>
                    <exception>org.apache.camel.RuntimeTransformException</exception>
                    <handled>
                        <constant>true</constant>
                    </handled>
                    <setHeader headerName="Exception">
                        <simple>XSLT Transformation failed with ${exception.message}</simple>
                    </setHeader>
                    <log message="Error in message processing. Exception message is: ${exception.message}" loggingLevel="ERROR" logName="com.test" />
                    <to uri="activemqLocal:queue:TEST.ERROR"/>
                </doCatch>
            </doTry>
        </route>

        <route id="file_out" startupOrder="4" autoStartup="true" streamCache="true">
            <from uri="direct:fileOut"/>
            <to uri="activemqLocal:queue:TEST.TEMP"/>
            <recipientList>
                <simple>file:///${in.header.CamelFileParent}/?fileName=../Out/${in.header.CamelFileNameOnly}</simple>
            </recipientList>
        </route>
    </camelContext>

Environment

  • Red Hat JBoss Fuse
    • 6.0.0

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content