picturised.. I know that it is possible to call routes from from different RouteContext xml,
How do I achieve it in hybrid manner, for an instance..
<route id=A>
<from uri="direct:A"/>
<to uri="bean:someprocess....."/>
<to uri="direct:endp_inside_routeBuilder"/>
<route id=B>
<from uri="direct:A"/>
<to uri="bean:routeBuilder?method=routeBuilderMethod"/>
<to uri="mock:endp"/>
is it possible to route to the consumer inside the bean...!
or is it possible to import the routeContext/route configured in Spring into the JavaDSL ?..
Related
I have apache camel application where huge number of routes are available and want to start it only when http request are made for them. For example, have two routes as mentioned in the documentation where autoStartup is set to false
<camelContext id="myCamel" xmlns="http://camel.apache.org/schema/spring"
autoStartup="false">
<route>
<from uri="direct:foo"/>
<to uri="mock:foo"/>
</route>
<route>
<from uri="direct:bar"/>
<to uri="mock:bar"/>
</route>
</camelContext>
I want to start the routes when the request are made for them. For example, when /rest/foo request made, I want to start the corresponding route and allow the corresponding route to serve the request.
The documentation says, we can start the route by using spring ApplicationContext.
ApplicationContext ac = ...
CamelContext camel = ac.getBean("myCamel", CamelContext.class);
// now start all the routes
camel.getRouteController().startAllRoutes();
should I write a filter program to intercept all http request and get hold spring context to start the corresponding route? or where do I have to put the above code to start the route exactly. can someone help please.
I have project A which has below simple route logrouteTest.xml
<routeContext id="CommonLogRoutes" xmlns="http://camel.apache.org/schema/spring">
<route id="logRoute">
<from id="_NSDL_PAN" uri="seda:MyLogRoute"/>
<convertBodyTo id="_convertBodyTo1" type="java.lang.String"/>
<log message="my received body : ${body}"/>
</route>
</routeContext>
I composed this project into JAR.
In my project B I have imported the above jar and trying to refer the Project A route like this
<import resource="classpath:com/tcl/Testjar/logrouteTest.xml"/>
Error
I am getting the below error
java.io.FileNotFoundException: class path resource [com/tcl/Testjar/logrouteTest.xml] cannot be opened because it does not exist
Is there any way to refer the external project camel route from current project route without deploying project A.
Note : I am looking for option to use Project A as ESB library
I'm a newbie Hazelcast. I'm trying to migrate my application from Ignite apache camel component to Hazelcast. I changed my old code (Apache Ignite) with new one (Hazelcast).
HazelCast
<setHeader headerName="CamelHazelcastOperationType">
<constant>put</constant>
</setHeader>
<to uri="hazelcast:map:${headers.token}" />
Apache ignite
<setHeader headerName="CamelJCacheAction">
<constant>PUT</constant>
</setHeader>
<setHeader headerName="CamelJCacheKey">
<simple>${headers.token}</simple>
</setHeader>
<to uri="jcache://accessTokensCache?cachingProvider=org.apache.ignite.cache.CachingProvider&cacheConfigurationProperties=#accessTokenJCacheConfigurationProperties&expiryPolicyFactory=#accessTokenExpirePolicyFactory&configurationUri=file:///{{application.base.dir}}/properties/ignite-config.xml" />
When i try to test the new code, i get this error :
StackTrace: java.lang.NullPointerException: Null key is not allowed!
Could you please show me how to migrate my old code to Hazelcast ?
Is there any documentation explaining how to migrate from apache ignite to Hazelcast?
Thanks in advance
We are upgrading from Apache Camel 2.12 to 2.16.4 and running into issues with one of the routes.
Caused by: java.lang.IllegalArgumentException: Missing ${ from the text: file:C:\OnDemandOutput?fileName=RPFPos_L2W.$simple{in.header.accountNum}-${date:now:yyyyMMddHHmmssSSS}.csv
<camelContext xmlns="http://camel.apache.org/schema/spring">
<propertyPlaceholder id="ignoreId" location="classpath:reformMB.properties"
prefixToken="${" suffixToken="}"/>
<route id="sendNotification">
<from uri="jms:queue:queue.sendNotification"/>
<to uri="file:${OnDemand.output.url}?fileName=RPFPos_L2W.$simple{in.header.accountNum}-${date:now:yyyyMMddHHmmssSSS}.csv"/>
</route>
</camelContext>
As per documentation this should have worked. Can someone help me in understanding what is wrong ?
According to the official documentation one should be able to refer to Camel's properties using $simple{...} like this:
Clashing Spring Property Placeholders with Camels Simple Language
Take notice when using Spring bridging placeholder then the spring ${} syntax clashes with the Simple in Camel, and therefore take care.
Example:
<setHeader headerName="Exchange.FILE_NAME">
<simple>{{file.rootdir}}/${in.header.CamelFileName}</simple>
</setHeader>
clashes with Spring property placeholders, and you should use $simple{} to indicate using the Simple language in Camel.
<setHeader headerName="Exchange.FILE_NAME">
<simple>{{file.rootdir}}/$simple{in.header.CamelFileName}</simple
</setHeader>
I am running servicemix 4.4.1. I am trying to make a http call to a website by using camel-http4. No matter which website I try to invoke, I keep getting this error:
org.apache.camel.RuntimeCamelException: org.apache.camel.component.http.HttpOperationFailedException: HTTP operation failed invoking http://servicemix.apache.org/downloads/servicemix-4.4.0.html with statusCode: 405
Here is my code snippet:
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="activemq://events1"/>
<setHeader headerName="CamelHttpMethod">
<constant>POST</constant>
</setHeader>
<to uri="http://servicemix.apache.org/downloads/servicemix-4.4.0.html"/>
<to uri="log:events"/>
</route>
</camelContext>
I have tried a number of sites and tried using different http methods (post vs get), and I keep getting the same error. Any idea? Thanks in advance.
The website you specified is no target of a form. So most likely it will only allow GET requests not POST. So try to set the CamelHttpMethod to GET.
Btw. what do you want to achieve with your route? If you want to send the activeMQ message to the website then POST is ok but you have to use a website that accepts POST.
You could achieve that by defining your own route to receive the request.
Then you can send to that url in the first route.
I checked this;
problem solved by set option 'bridgeEndpoint';
You are setting the http endpoint to be bridgeEndpoint which means the request url will be updated with request URI.
<route>
<from uri="-------"/>
<to uri="jetty://http://localhost:9090/my.html?bridgeEndpoint=true"/
<to uri="log:events"/>
</route>