java - How to make Infinispan work with camel -
import org.apache.camel.builder.routebuilder; import org.apache.camel.component.infinispan.infinispanconstants; import org.apache.camel.component.jackson.jacksondataformat; import org.apache.camel.model.dataformat.jsonlibrary; import uk.co.sammy.model.collection; public class infinispanroute extends routebuilder { private jacksondataformat json = new jacksondataformat(collection.class); @override public void configure() throws exception { from("file:src/data?noop=true&include=.*.json") .choice() .when() .jsonpath("$..custinfo[?(@.firstname == 'sammy')]").unmarshal(json) .log("got customer data ${body.custinfo.firstname}") .setheader(infinispanconstants.operation, constant(infinispanconstants.put_if_absent)) .setheader(infinispanconstants.key, simple("${body.custinfo.firstname}")) .to("infinispan://localhost") .marshal().json(jsonlibrary.jackson) .to("activemq:queue:incomingapplication", "activemq:queue:customerdetails"); from("activemq:queue:incomingapplication") .setheader(infinispanconstants.operation, constant(infinispanconstants.get)) .setheader(infinispanconstants.key, constant("${body.custinfo.firstname}")) .to("infinispan://foo?cachename=localcache") .setbody(simple("${header.camelinfinispanoperationresult}")) .to("activemq:output"); } }
my pom.xml looks below
<properties> <activemq.version>5.14.1</activemq.version> <camel.version>2.18.0</camel.version> <infinispan.version>8.3.0.final-redhat-1</infinispan.version> <camel-jbossdatagrid.version>6.6.1.final-redhat-1</camel-jbossdatagrid.version> </properties> <dependencies> <dependency> <groupid>org.apache.camel</groupid> <artifactid>camel-core</artifactid> <version>${camel.version}</version> </dependency> <dependency> <groupid>org.apache.camel</groupid> <artifactid>camel-jackson</artifactid> <version>${camel.version}</version> </dependency> <dependency> <groupid>org.apache.camel</groupid> <artifactid>camel-jsonpath</artifactid> <version>${camel.version}</version> </dependency> <dependency> <groupid>org.infinispan</groupid> <artifactid>infinispan-embedded</artifactid> <version>${infinispan.version}</version> </dependency> <dependency> <groupid>org.apache.camel</groupid> <artifactid>camel-jbossdatagrid</artifactid> <version>${camel-jbossdatagrid.version}</version> </dependency> <!--activemq --> <dependency> <groupid>org.apache.activemq</groupid> <artifactid>activemq-camel</artifactid> <version>${activemq.version}</version> </dependency> <dependency> <groupid>org.apache.activemq</groupid> <artifactid>activemq-pool</artifactid> <version>${activemq.version}</version> </dependency> <dependency> <groupid>org.projectlombok</groupid> <artifactid>lombok</artifactid> <version>1.16.10</version> </dependency> <dependency> <groupid>org.ow2.asm</groupid> <artifactid>asm-all</artifactid> <version>5.1</version> </dependency> </dependencies> <repositories> <repository> <id>fuse-release</id> <name>jboss release repository</name> <releases> <updatepolicy>never</updatepolicy> </releases> <snapshots> <enabled>false</enabled> </snapshots> <url>http://repo.fusesource.com/nexus/content/groups/public/</url> </repository> </repositories> </project>
i have tried 3 days simple sample code work infinispan using redhat getting started guide , downloaded quickstart zip run still won't work! keep getting error "cannot connect foo:11222" or "pool not open" spring jms warning mixing uber , jars version. started off using ehcache pain implement because of limited simple examples show how store, retrieve , clear cache rest calls etc. now, need work can migrate openshift but, still won't work! every time restart project, different errors. please step step setup infinispan work using above code appreciated. guys!
p.s: i've read through redhat data grid getting started page , followed instructions before doing last resort!!!
using "infinispan://localhost" uri format try connect infinispan server. use embedded cache, should use "infinispan://?cachename=localcache"
Comments
Post a Comment