I am trying to do a get request to the following url:
http://hellostackexchange?mynameiskees.json
the problem is that i don't see how i can add the option parameters after i have added the query parameters to the uri. My attempt is the following:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route id="hello stackexchange">
<from uri="timer://counting_camera?fixedRate=true&period=1000" />
<setHeader headerName="CamelHttpQuery">
<simple>"mynameiskees.json"</simple>
</setHeader>
<to uri=http4://hellostackexchange/>
<to uri = "direct:test"/>
</route>
<route id = "final">
<from uri="direct:test?authUsername=kees&authPassword=kees"/>
<to uri="log:result"/>
</route>
</camelContext>
this results in the error:
There are 2 parameters that couldn't be set on the endpoint. Check the uri
if the parameters are spelt correctly and that they are properties of the
endpoint. Unknown parameters=[{authPassword=kees, authUsername=kees}]
any tips on how to do this?
Withe the help of #Namphibian i did the following, you can just add your query parameters to a header and add the options to your uri:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route id="hello stackexchange">
<from uri="timer://counting_camera?fixedRate=true&period=1000" />
<setHeader headerName="CamelHttpQuery">
<simple>"mynameiskees.json"</simple>
</setHeader>
<to uri="http4://hellostackexchange?authUsername=kees&authPassword=kees"/>
<to uri = "log:result"/>
</route>
</camelContext>
Related
<from uri="direct:validating-route" />
<setBody>
<simple>${body}</simple>
</setBody>
<log message="Mapping request from source to destination"
loggingLevel="INFO" />
<to
uri="dozer:transformValidateWrapperType?mappingFile=mappings/validate-mapping.xml&targetModel=in.map.loc.elements.ValidateWrapperType" />
<log message="Completed MApping and sending request"
loggingLevel="INFO" />
<setBody>
<simple>${body}</simple>
</setBody>
<setHeader headerName="operationNamespace">
<constant>http://in.map.com/functions/tele/ap</constant>
</setHeader>
<to uri="cxf:bean:validateOutside" />
The body passed after the set body is null. This is the route for a SOAP request. How to get In the body of the exchange with the needed classes object in the camel route itself?
I have a route from which I am trying to call a seda queue. I wanted to use a property which has been set in my current route to the seda queue. The below is the piece of code that I have been used, but it doesn't seems to be working as expected.
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route id="route1">
<!-- Method initialize the JobDetails class with values jobName="jobTest" and jobMode="mode1" -->
<bean ref="jobDetails" method="createJobDetails"/>
<to uri="activemq:queue:myqueue?disableReplyTo=true" />
</route>
<route id="route2">
<from uri="activemq:queue:myqueue" />
<convertBodyTo type="my.package.JobDetails" />
<setProperty propertyName="JOB_DETAILS">
<simple>${body}</simple>
</setProperty>
<recipientList>
<simple>direct-vm:testDirect-${property.JOB_DETAILS.jobName}</simple>
</recipientList>
</route>
</camelContext>
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route id="route3">
<from uri="direct-vm:testDirect-jobTest" />
<!-- Some business logic based on the job mode-->
<setProperty propertyName="JOB_MODE">
<simple>mode1</simple>
</setProperty>
<to uri="seda:testSeda?blockWhenFull=true" />
</route>
<route id="sedaRoute">
<from uri="seda:testSeda?concurrentConsumers=5" />
<log message="Message from firstRoute: ${property.JOB_MODE}" />
<!-- Perform some business logic based on the job mode -->
</route>
</camelContext>
Appreciated help!!!
I am sending a request to a rest api from queue, and getting a response back.if the response is not 201 then I have to push the same request to the queue again for a second time. But when I am pushing it to the queue, I am getting an error, like the one below:
org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 20000 millis due reply message with correlationID: Camel-ID-01HW828056-64538-1479908182896-32-4 not received on destination: temp-queue://ID:01HW828056-64546-1479908191870-15:3:1.
this is my blueprint.xml
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
xmlns:cxf-core="http://cxf.apache.org/blueprint/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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/cxf http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<camelContext xmlns="http://camel.apache.org/schema/blueprint" trace="false">
<route id="fromqueuecontext">
<from uri="activemq:queue:request?asyncConsumer=true"/>
<unmarshal>
<jaxb partClass="partclassname" prettyPrint="true" contextPath="contextname"/>
</unmarshal>
<setProperty propertyName="capturequeuebean">
<simple>${body}</simple>
</setProperty>
<log message="${property.capturequeuebean.orderNum}"/>
<log message="${property.capturequeuebean.transactionNumber}"></log>
<removeHeaders pattern="*" />
<setHeader headerName="CamelHttpMethod" id="_setHeader1">
<constant>PUT</constant>
</setHeader>
<setHeader headerName="Content-Type" id="_setHeader2">
<constant>application/json</constant>
</setHeader>
<setBody>
<simple>${body.captureRequest}</simple>
</setBody>
<marshal>
<json library="Jackson"/>
</marshal>
<log message="sending body ${body}"/>
<convertBodyTo type="java.io.InputStream" id="_convertBodyTo1" />
<recipientList>
<simple><!--url to be sent --></simple>
</recipientList>
<log message="${header.CamelHttpResponseCode}" />
<choice>
<when>
<simple>${header.CamelHttpResponseCode} != 201 and ${property.capturequeuebean.count} > 0</simple>
<log message="inside 1st when"></log>
<setBody>
<simple>${property.capturequeuebean}</simple>
</setBody>
<bean ref="CaptureBusinessImpl" method="changecount"></bean>
<log message="${body.count}"></log>
<to uri="activemq:queue:request" />
</when>
<otherwise>
<choice>
<when>
<simple>${header.CamelHttpResponseCode} == 201 </simple>
<log message="Sucess"></log>
</when>
<otherwise>
<choice>
<when>
<simple>${property.capturequeuebean.count} == 0</simple>
<log message="exception"></log>
</when>
</choice>
</otherwise>
</choice>
</otherwise>
</choice>
</route>
</camelContext>
</blueprint>
Somewhere a JMSReplyTo header is being specified and the activemq component is creating a consumer on a temp-queue waiting for a response. The response is not being returned in 20,000 ms, so the activemq component is giving up and throwing the error.
The automatic replyTo handling can be disabled by adding the following options to the activemq endpoint:
?disableReplyTo=true&preserveMessageQos=true
See notes here: Camel JMS Component
I have following camel routing configuration.
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<!-- Rest Configuration -->
<restConfiguration component="jetty" port="9092" bindingMode="auto">
<dataFormatProperty key="json.in.disableFeatures" value="FAIL_ON_UNKNOWN_PROPERTIES" />
</restConfiguration>
<rest path="/" consumes="application/json"
produces="application/json">
<post uri="/" type="com.aaa.xxxx.esb.config.xxxxEsbJsonMapping">
<route>
<setHeader headerName="Authorization">
<simple>Basic YWRtaXXXXWRtaW4=</simple>
</setHeader>
<setHeader headerName="CamelHttpMethod">
<constant>POST</constant>
</setHeader>
<setHeader headerName="CamelHttpMethod">
<constant>POST</constant>
</setHeader>
<setHeader headerName="RestEndpointURL">
<simple>
http://${body.serviceURL}?bridgeEndpoint=true
</simple>
</setHeader>
<setBody>
<simple>{"UserDetails": ${body.serviceDataJsonObj}}</simple>
</setBody>
<log message="Exchanged headers : ${headers.RestEndpointURL}" />
<recipientList>
<simple>${headers.RestEndpointURL}</simple>
</recipientList>
</route>
</post>
</rest>
What I need to know is where I can set
matchOnUriPrefix=true
option for the jetty component which I have already configured for camel rest.
According to the Claus Ibsen answer, I changed configuration XML as follows.
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<!-- Rest Configuration -->
<restConfiguration component="jetty" port="9092"
bindingMode="auto">
<dataFormatProperty key="json.in.disableFeatures"
value="FAIL_ON_UNKNOWN_PROPERTIES" />
<componentProperty key="matchOnUriPrefix" value="true" />
</restConfiguration>
<!-- Rest Services -->
<rest path="/" consumes="application/json" produces="application/json">
<post uri="/" type="com.aaa.xxxx.esb.config.xxxxEsbJsonMapping">
<route>
<setHeader headerName="Authorization">
<simple>Basic YWRXXX46YWRtaW4=</simple>
</setHeader>
<setHeader headerName="CamelHttpMethod">
<constant>POST</constant>
</setHeader>
<setHeader headerName="CamelHttpMethod">
<constant>POST</constant>
</setHeader>
<setHeader headerName="RestEndpointURL">
<simple>
http://${body.serviceURL}?bridgeEndpoint=true
</simple>
</setHeader>
<setBody>
<simple>{"SystemUserDetails": ${body.serviceDataJsonObj}}</simple>
</setBody>
<log message="Exchanged headers : ${headers.RestEndpointURL}" />
<recipientList>
<simple>${headers.RestEndpointURL}</simple>
</recipientList>
</route>
</post>
</rest>
</camelContext>
I'm using servicemix apache-servicemix-7.0.0.M2
I upgraded its camel ver 2.16.3 to 2.17.3
Thanks
The rest-dsl is configured using the componentProperty in the restConfiguration:
<restConfiguration component="jetty" port="9092" bindingMode="auto">
<componentProperty key="matchOnUriPrefix" value="true"/>
<dataFormatProperty key="json.in.disableFeatures" value="FAIL_ON_UNKNOWN_PROPERTIES" />
</restConfiguration>
You can find details about this in the documentation: http://camel.apache.org/rest-dsl
U may add inside
route
tag as below:
<route>
<from uri="jetty://foo?matchOnUriPrefix=true"/>
...
</route>
I am routing a message from queue->converting it using xslt and forwarding it to another queue, log.
My Camel configuration is as follows:
<camelContext xmlns="http://camel.apache.org/schema/spring"
streamCache="true">
<route>
<from uri="jms:queue:TradeEventsToESBQueue" />
<multicast>
<to uri="xslt:com/tpt/esb/tradeevent/confirmation.xsl" />
<to uri="xslt:com/tpt/esb/tradeevent/valuation.xsl" />
</multicast>
</route>
<route>
<from uri="xslt:com/tpt/esb/tradeevent/confirmation.xsl" />
<to uri="log:output?showAll=true" />
</route>
<route>
<from uri="xslt:com/tpt/esb/tradeevent/valuation.xsl" />
<to uri="jms:queue:TradeValuationStartQueue1?jmsMessageType=Text" />
<to uri="log:output?showAll=true" />
</route>
</camelContext>
On running the program i get the following error:
Caused by: org.apache.camel.ExpectedBodyTypeException: Could not
extract IN message body as type: interface javax.xml.transform.Source
body is: null at
org.apache.camel.builder.xml.XsltBuilder.getSource(XsltBuilder.java:482)[64:org.apache.camel.camel-core:2.10.1]
at
org.apache.camel.builder.xml.XsltBuilder.process(XsltBuilder.java:125)[64:org.apache.camel.camel-core:2.10.1]
at
org.apache.camel.impl.ProcessorPollingConsumer.receive(ProcessorPollingConsumer.java:58)[64:org.apache.camel.camel-core:2.10.1]
Any ideas what is causing this issue?
You should not use the XSLT component in that manner.
You should particularly not try to use "from" with XSLT, but rather use it in combination with any internal transport component (directly for the instance). I think the following will do what you want.
<route>
<from uri="jms:queue:TradeEventsToESBQueue" />
<multicast>
<to uri="direct:confirmation"/>
<to uri="direct:valuation"/>
</multicast>
</route>
<route>
<from uri="direct:confirmation"/>
<to uri="xslt:com/tpt/esb/tradeevent/confirmation.xsl" />
<to uri="log:output?showAll=true" />
</route>
<route>
<from uri="direct:valuation"/>
<to uri="xslt:com/tpt/esb/tradeevent/valuation.xsl" />
<to uri="jms:queue:TradeValuationStartQueue1?jmsMessageType=Text" />
<to uri="log:output?showAll=true" />
</route>