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
Related
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
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 have jsut upgraded my camel version and some functionality that was working before version 2.16.0 is now broken, I used to be able to get the URI for a toDefinition that replaced a placeholder, having just upgraded, this now doesnt replace the placeholder.
Code example is as follows:
<propertyPlaceholder id="properties" location="config.properties" />
<route>
<from uri="direct:input" />
<to uri="mq:queue:{{MY_PLACEHOLDER}}" />
</route>
config.properties
MY_PLACEHOLDER=FOO
Camel version 2.15.5
toDefinition.getUri() // equals mq:queue:FOO
Camel version 2.16.0
toDefinition.getUri() // equals mq:queue:{{MY_PLACEHOLDER}}
Any ideas?
Yes that is how its intended to be. The model is the model as it was designed (in this case with placeholder value).
The resolved uri is when Camel startup and runs the routes. So you can take that uri, and ask Camel to resolve, there is an API on CamelContext for that resolvePropertyPlaceholders
http://static.javadoc.io/org.apache.camel/camel-core/2.18.2/org/apache/camel/CamelContext.html#resolvePropertyPlaceholders-java.lang.String-
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 ?..
This is the example that is bundled with apache camel binaries
<route>
<!-- incoming requests from the servlet is routed -->
<from uri="servlet:///hello"/>
<choice>
<when>
<!-- is there a header with the key name? -->
<header>name</header>
<!-- yes so return back a message to the user -->
<transform>
<simple>Hello ${header.name} how are you?</simple>
</transform>
</when>
<otherwise>
<!-- if no name parameter then output a syntax to the user -->
<transform>
<constant>Add a name parameter to uri, eg ?name=foo</constant>
</transform>
</otherwise>
</choice>
</route>
How to translate this to Java
Am a beginner in camel, and some how came up to this
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder(){
public void configure(){
from("servlet://hello").transform().....
}
});
But dont know how to proceed further...
If you want to port it over to java without any XML (spring that is) you can't (easily) use the servlet component.
Just porting the route will be like:
from("servlet:///hello")
.choice()
.when()
.header("name")
.transform(simple("Hello ${header.name} how are you?"))
.otherwise()
.transform(constant("Add a name parameter to uri, eg ?name=foo"));
It should work in the spring example (or any spring web app), just replacing the <route> in the <CamelContext> with <routeBuilder ref="demoRoute"> given you have defined your route as a spring bean (<bean id="demoRoute" class="org.example.demo.DemoRoute">).
However, I guess you want to do this in plain java (no spring, no xml, no webapp). You could go with the Jetty component. The difference being that Camel then will start the servlet container, instead of the servlet container starting Camel. No difference for this simple example though.
I suggest you start out with a Maven archetype to get the skeleton up
e.g. mvn archetype:generate then choose org.apache.camel.archetypes:camel-archetype-java (Creates a new Camel project using Java DSL.)
Well, you don't need the maven archetype if you have your own java application and have the thread keep running. Then you should do fine with your approach. The maven archetype is however very good for training purposes.
You then need to add a dependency to Jetty (camel-jetty.jar) (read more here).
The actual route would be exactly the same except the first row: from("jetty:http://localhost:8080/camel/hello")
Nice and easy.
Try this one:
from("servlet://hello")
.choice()
.when(header("name").isNotNull()).transform(simple("Hello ${header.name} how are you?"))
.otherwise().transform(constant("Add a name parameter to uri, eg ?name=foo"));