camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MichaelAtSAG <mebevilac...@gmail.com>
Subject Velocity without java
Date Fri, 02 Dec 2011 18:46:20 GMT
The Apache Camel example for Velocity using Java code to implement the logic.
Is there an example available that does not use java?

We are trying to use a Spring XML approach and cannot figure out how to
connect the message properties into the velocity template.

-Velocity template:-

Dear Purchaser,

We have an ${headers.eventtype} situation. We need
${body.DesiredInventoryLevel} piece(s) for part number ${body.ItemID}.

Please review this situation.



-Message:-
<?xml version="1.0" encoding="UTF-8"?>
<evt:Event xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:evt="http://namespaces.xyz.com/EDA/Event"
	xmlns:pay="http://namespaces.xyz.com/EDA/WebM/Sample/InventoryMgmt/1.0">
    <evt:Body>
        <pay:PartInventoryShortage>
            <pay:Part>
                <pay:ItemID>ABC123</pay:ItemID>
                <pay:ItemName>Widget for thingy</pay:ItemName>
                <pay:Model>ACME </pay:Model>
                <pay:Color>Grey</pay:Color>
                <pay:Shape>Oval</pay:Shape>
            </pay:Part>
            <pay:InventoryLevel>5</pay:InventoryLevel>
            <pay:DesiredInventoryLevel>45</pay:DesiredInventoryLevel>
            <pay:SupplierInventoryLevel>28</pay:SupplierInventoryLevel>
        </pay:PartInventoryShortage>
    </evt:Body>
</evt:Event>

-Content file -

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="        http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd       
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">

	<camelContext xmlns="http://camel.apache.org/schema/spring" id="camel"
		xmlns:evt="http://namespaces.xyz.com/EDA/Event">

		<route id="Announcer" startupOrder="3">
			<from uri="file:src/data?noop=true" />
			<setHeader headerName="eventtype">
				<xpath>/evt:Event/evt:Header/evt:Type</xpath>
			</setHeader>
			<choice>
				<when>
					<language language="xpath">$eventtype =
					
'{http://namespaces.xyz.com/EDA/WebM/Sample/InventoryMgmt/1.0}PartInventoryShortage'
					</language>
					<log message="Announce PartInventoryShortage(b): file - &gt;
jms:InvMgmt" />
					<to uri="velocity:file:src/main/resources/email.vm" />
					<log message="Announce PartInventoryShortage(a): file - &gt; email" />
					
					<to uri="outputToScreen" />
				</when>
			</choice>
		</route>
	</camelContext>
</beans>


How do I connect the message properties with the velocity template? Do I
need to set header properties in the Camel context file? I did this for
routing logic, yet the header element shows like this:

We have an *com.sun.org.apache.xml.internal.dtm.ref.DTMNodeList@4e39f16f*
situation.


--
View this message in context: http://camel.465427.n5.nabble.com/Velocity-without-java-tp5042885p5042885.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message