http://www.osgi.org/xmlns/blueprint/v1.0.0 https://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">
<camelContext id="cbr-example-context" xmlns="http://camel.apache.org/schema/blueprint">
<route id="cbr-route">
<from id="_from1" uri="file:///d:/inxslt"/>
<transform.xslt from="_from1" to="_to3" xsltFile="src/main/java/com/xslt/converterXsl.xsl"/>
<to id="_to3" uri="file:///d:/outxslt"/>
</route>
</camelContext>
i want to use my converterXsl.xsl format class to transform xml which is in file:///d:/inxslt this path
i tried this further here not not working
try to use the following definition of the Camel route.
<camelContext id="_context1" xmlns="http://camel.apache.org/schema/blueprint">
<route id="_route1">
<from id="_from1" uri="file:src/data?noop=true"/>
<to id="_to1" uri="xslt:file:src/xml2html.xsl"/>
<to id="_to2" uri="file:target/output"/>
</route>
</camelContext>
Please, adjust file paths to your needs. Especially, notice notation of XSLT component.
I hope it helps ;-)
Related
We have a route that will accept the kafka.KEY and use that as mqtt url parameter to send the data to the right topic.
<routes
xmlns="http://camel.apache.org/schema/spring">
<route id="KafkaToMQTT">
<from uri="kafka://mqtt?brokers=localhost:9092"/>
<to uri="micrometer:timer:camel.proxy.kafka.mqtt.stream?action=start"/>
<log message="Headers ${header.kafka.KEY}"/>
<to uri="mqtt:mqtt?host=tcp://localhost:1883&publishTopicName=try${header.kafka.KEY}"/>
<to uri="log://camel.proxy?groupInterval=3&level=INFO"/>
<to uri="micrometer:timer:camel.proxy.kafka.mqtt.stream?action=stop"/>
</route>
</routes>
In the log messages I see the ${header.kafka.KEY} correctly, while in the mqtt I'm getting the topic as literally try${header.kafka.KEY}
What is the reason for that, how to make the header to be used there?
To avoid that the right element instead of to should be used, that is toD.
toD concatenates the url correctly, so the right route XML is:
<routes
xmlns="http://camel.apache.org/schema/spring">
<route id="KafkaToMQTT">
<from uri="kafka://mqtt?brokers=localhost:9092"/>
<to uri="micrometer:timer:camel.proxy.kafka.mqtt.stream?action=start"/>
<log message="Headers ${header.kafka.KEY}"/>
<toD uri="mqtt:mqtt?host=tcp://localhost:1883&publishTopicName=ESP_02/try${header.kafka.KEY}"/>
<to uri="log://camel.proxy?groupInterval=3&level=INFO"/>
<to uri="micrometer:timer:camel.proxy.kafka.mqtt.stream?action=stop"/>
</route>
</routes>
I have some problem. I need to take the route or all CamelContext from blueprint file. How can i did it?
route.xml
I have tried to add route via RouteDefinitions but it throws exceptions because it expected spring namespace but i use blueprint namespace. I use cxf as implementation of JAX-RS. There is another way how to do it better.
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<bean id="weatherMailService" class="com.test.mail.MailSenderImpl"/>
<service ref="weatherMailService" interface="com.test.mail.MailSender"/>
<bean id="serviceProcessor" class="com.test.mail.MailSenderImpl"/>
<bean id="context" class="com.test.mail.MailSenderImpl"></bean>
<camelContext id="ctx" xmlns="http://camel.apache.org/schema/blueprint">
<route id="mail">
<from uri="direct:start"/>
<setBody>
<constant>Test</constant>
</setBody>
<setHeader headerName="subject">
<simple>Weather</simple>
</setHeader>
<process ref="serviceProcessor"/>
<to uri="smtps://smtp.gmail.com:465?username=RAW(*****#gmail.com)&password=******&to=******#gmail.com"/>
<to uri="log:start"/>
<process ref="context"></process>
</route>
</camelContext>
I would like to get CamelContext in java code. How can i did it? Thank you
I have written my route using spring xml which looks like this
<camelContext xmlns="http://camel.apache.org/schema/spring">
<propertyPlaceholder id="properties" location="classpath:props.properties" />
<route>
<from
uri="activemq:queue:adapter.queue?mapJmsMessage=false&disableReplyTo=true" />
<log message="This is a status request"></log>
<process ref="psuedoRoute"></process>
</route>
</camelContext>
As I am getting a Java POJO through my activemq end point, and that is the exchange body. Is it possible to read the value of a string member within this route xml itself?
Yes, its possible. You may use SPEL, it allows to call a method of Java object, getter in your case.
It could be like:
<camelContext xmlns="http://camel.apache.org/schema/spring">
<propertyPlaceholder id="properties" location="classpath:props.properties" />
<route>
<from
uri="activemq:queue:adapter.queue?mapJmsMessage=false&disableReplyTo=true" />
<log message="This is a status request"></log>
<process ref="psuedoRoute"></process>
<log message="This is a status request"></log>
<setBody>
<spel>#{body.getValue()}</spel>
</setBody>
</route>
</camelContext>
A short question about Apache Camel.
I have the following scenario, where my server receives jms messages and then transform to csv file and then insert DB.
For this purpose i have 2 beans:
xml2csv
insertDB
I use routing like:
<route id="route1" errorHandlerRef="myErrorHandler">
<from uri="file://{someFolder1}}
?...
<to uri="bean:xml2csv" />
<log message="transformed to xml file" />
</route>
<route id="route2" errorHandlerRef="myErrorHandler">
<from uri="file://{{someFolder2}}
?...
<to uri="direct:csvOnboardingChannel" />
</route>
<route id="csvOnboarding" errorHandlerRef="myErrorHandler">
<from uri="direct:csvOnboardingChannel" />
<to uri="bean:insertDB" />
</route>
When "route" a file from-to, is it move like a message? or putting the question different, does Apache Camel take a file, wrap it as a message and route it to a bean or a component?
Do I understand it correct or am in a wrong directation.
Yes, your understanding is correct. Camel reads in the file's data and sends it as a message through the route to a bean. Might also be simpler as a single route, like so:
<route id="route1" errorHandlerRef="myErrorHandler">
<from uri="file://{someFolder1}}">
<to uri="bean:xml2csv" />
<to uri="bean:insertDB" />
</route>
I am trying to create a Spring WS consumer like this:
<route>
<from uri="direct:start"/>
<to uri="spring-ws:rootqname:http://{ip}:{port}/PORTAL/webservices/A20?soapAction=acceptMessage"/>
<to uri="log:output"/>
</route>
Error:
SOAPAction http://{ip}:{port}/PORTAL/webservices/A20/acceptMessage does not match an operation
In your property placeholders you need to use double braces like so:
<route>
<from uri="direct:start"/>
<to uri="spring-ws:rootqname:http://{{ip}}:{{port}}/PORTAL/webservices/A20?soapAction=acceptMessage"/>
<to uri="log:output"/>
</route>
More info here: http://camel.apache.org/using-propertyplaceholder.html