I am able to called Web Service, now what ever response came from web service, i need to fetch same response in java code so that i am able to further processing.
<camelContext xmlns="http://camel.apache.org/schema/spring" trace="false">
<route id="my_Sample_Camel_Route_with_CXF">
<from uri="file:src/data?noop=true"/>
<log loggingLevel="INFO" message=">>> ${body}"/>
<to uri="cxf://http://www.webservicex.net/stockquote.asmx?wsdlURL=src/main/resources/META-INF/stockquote.wsdl&serviceName={http://www.webserviceX.NET/}StockQuote&portName={http://www.webserviceX.NET/}StockQuoteSoap&dataFormat=MESSAGE"/>
<log loggingLevel="INFO" message=">>> ${body}"/>
</route>
Instead of logging using
Related
I have a Camel route that looks something like the one below. If all records parse successfully, then I get an email from the onCompletion step. If one record gets an exception then the rest of the records will process, which is fine, but the onCompletion step does not fire.
What I'd like is for the onCompletion step to run even if there are errors and to be able to send a message saying "route completed with errors". How can I do this?
<route id="route1">
<from uri="file://C:/TEMP/load?noop=true&idempotentRepository=#sysoutStore&sorter=#externalDataFilesSorter"/>
<choice>
<when>
<simple>${file:name} regex '*file.*.(txt)'</simple>
<to uri="direct:RouteFile" />
</when>
</choice>
</route>
<route id="testRouteDirect">
<from uri="direct:RouteFile" />
<onException>
<exception>java.lang.IllegalArgumentException</exception>
<redeliveryPolicy maximumRedeliveries="1" />
<handled>
<constant>true</constant>
</handled>
<to uri="log:java.lang.IllegalArgumentException"></to>
</onException>
<onException>
<exception>java.text.ParseException</exception>
<redeliveryPolicy maximumRedeliveries="1" />
<handled>
<constant>true</constant>
</handled>
<to uri="log:java.text.ParseException"></to>
</onException>
<split parallelProcessing="false" strategyRef="exchangePropertiesAggregatorStrategy" >
<tokenize token="\r\n"/>
<to uri="log:Record"></to>
</split>
<onCompletion>
<to uri="log:completion"></to>
<to uri="smtp://mail.com?contentType=text/html&to=done#test.com&from=route#test.com&subject=we're done" />
</onCompletion>
</route>
The best part of your route is, you have onException inside your route with handled=true. So move your onCompletion to the parent route(route1), It should work !
There are a bunch of tickets related to oncompletion on the camel site: Camel Jira URL. I upgraded to a newer version of camel & I don't get this issue any more.
I am trying to set up a very simple route to send SOAP content over http and then show the response:
<route>
<from uri="direct:start"/>
<setBody>
<constant><![CDATA[<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/"><SOAP:Header></SOAP:Header><SOAP:Body></SOAP:Body></SOAP:Envelope>]]>
</constant>
</setBody>
<to uri="https://localhost:8443/api"/>
<log message="${out.body}"/>
</route>
I am not getting any error but is not really showing the response.
What am I missing here?
I am simply runnig my app like this:
public class App {
public static void main( String[] args ) {
ApplicationContext
ctx = new ClassPathXmlApplicationContext("META-INF/spring/camel-config.xml");
}
}
You have not set some headers.
Try to modify your route like below:
<route>
<from uri="timer://foo?fixedRate=true&period=60000"/>
<setHeader headerName="CamelHttpMethod">
<constant>POST</constant>
</setHeader>
<setHeader headerName="Content-type">
<constant>text/xml;charset=UTF-8</constant>
</setHeader>
<setHeader headerName="Accept-Encoding">
<constant>gzip,deflate</constant>
</setHeader>
<setBody>
<constant><![CDATA[<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/"><SOAP:Header></SOAP:Header><SOAP:Body></SOAP:Body></SOAP:Envelope>]]>
</constant>
</setBody>
<to uri="https://localhost:8443/api"/>
<log message="${out.body}"/>
</route>
I have changed the beginning of the route, because I don't know how you're sending messages to direct:start.
One of my client put the file request under directory placeorder with below configuration in CAMEL
<route id="FileToJMS">
<from uri="file:target/placeorder" />
<to uri="jms:incomingOrders" />
</route>
Once processing is done from incomingOrders, i want to send the some response to customer who initiated file request. How can i achieve it with CAMEL (probably using request reply or return address pattern). Any ideas?
Like so:
<route id="FileToJMS">
<from uri="file:target/placeorder" />
<to uri="jms:incomingOrders" />
<to uri="mock:response"/>
</route>
replace "mock:response" with whatever component you want to send the response with
I have a simple route in camel, which reads messages from an activemq queue 'A' and writes it to another activemq queue 'B'.I was able to get this to this part to work.
But I need to add a new property to the message before writing it to 'B'. I have tried to add the property 'prop1' to the message using the Spring DSL below, but the property is not being added to the message.
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="activemq:queue:A"/>
<setProperty propertyName="prop1">
<simple>prop1Value</simple>
</setProperty>
<to uri="activemq:queue:B"/>
</route>
</camelContext>
Is this the correct way to add a property to a message in SPRING DSL?
Use a header instead of a property:
<route>
<from uri="activemq:queue:A"/>
<setHeader headerName="prop1">
<constant>prop1Value</constant>
</setHeader>
<to uri="activemq:queue:B"/>
</route>
<route>
<from uri="activemq:queue:B" />
<log message="prop1 = ${header.prop1}" />
</route>
Camel headers are transferred to JMS properties which are transferred back to Camel headers as can be seen looking at the implementation of org.apache.camel.component.jms.JMSBinding. The Camel properties are skipped.
I have a situation where I want to pass data into an Aggregator, but I don't want the aggregator to do anything until it has received messages from 3 distinct routes:
<route id="route-1">
<from uri="direct:fizz" />
<to uri="bean:bean1?method=process" />
<setHeader headerName="id">
<constant>1</constant>
</setHeader>
<to uri="direct:aggregator" />
</route>
<route id="route-2">
<from uri="direct:buzz" />
<to uri="bean:bean2?method=process" />
<setHeader headerName="id">
<constant>2</constant>
</setHeader>
<to uri="direct:aggregator" />
</route>
<route id="route-3">
<from uri="direct:foo" />
<to uri="bean:bean3?method=process" />
<setHeader headerName="id">
<constant>3</constant>
</setHeader>
<to uri="direct:aggregator" />
</route>
<route id="aggregator-route">
<from uri="direct:aggregator" />
<aggregate strategyRef="myAggregationStrategy" completionSize="1">
<correlationExpression>
<simple>header.id</simple>
</correlationExpression>
<to uri="bean:lastBean?method=process" />
</aggregate>
</route>
The way this is configured, when the aggregator's completionSize is set to 1 or 2, the aggregated Exchange is routed on to my lastBean. However, if I set completionSize to 3, for some reason, lastBean#process never gets invoked.
I'm sure that I'm using header.id and the aggregator incorrectly here. In the correlationExpression, I just need to make sure that we have 1 Message from each of the 3 routes.
So my question: what do I need to do to make my aggregator "wait" until it has received 1 message from route-1, 1 message from route-2 and 1 message from route-3?
If you are correlating messages from three routes, there needs to be a way for them all to have a matching header.id value by the time they reach the aggregating route.
In your example, each route sets a different id value so there would be no match. If you set the id value to "1" in each route, I think it would start to work as expected.