You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by austin solomon <au...@gmail.com> on 2017/06/08 09:29:10 UTC

Using Camel-Ignite for inserting json object to Ignite's Cache

Hi,

I'm trying to listen from an mqtt topic which produces a json object and
store that data into apache Ignite's Cache using Apache camel contex, but
the data is not inserting to cache.

my JSON data looks like this : {"id": 1, "data":"test"}

and this is sample code snippet : 

         from("mqtt:bar?subscribeTopicName=test&host=tcp://localhost:1883")
	.setHeader("id", new JsonPathExpression("$.id")) 
	.setHeader("data", new JsonPathExpression("$.data"))
        .process(new Processor() {
		public void process(Exchange exchange)throws Exception {
                         exchange.getIn().setBody(
exchange.getIn().getBody(String.class));
		         System.out.println("Processing JSON Meassage: "+
exchange.getIn().getBody(String.class));
                }
	})
	.to("ignite-cache:cache:myCacheName?operation=PUT");

Can anyone help me what I am missing.

How to insert the Key-Value into Ignite's cache and query it later.








--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Using-Camel-Ignite-for-inserting-json-object-to-Ignite-s-Cache-tp13513.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Using Camel-Ignite for inserting json object to Ignite's Cache

Posted by vkulichenko <va...@gmail.com>.
Hi Austin,

Can you ask Camel community about this? I'm not sure if this is a valid test
or not.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Using-Camel-Ignite-for-inserting-json-object-to-Ignite-s-Cache-tp13513p14296.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Using Camel-Ignite for inserting json object to Ignite's Cache

Posted by austin solomon <au...@gmail.com>.
Hi Val,

I'm just playing around with Camel-Ignite component for a POC. my goal is to
parse the JSON data and put it to Ignite's cache.

I got the syntax from Camel-Ignite component's test project [1]

After some changes in my code now the data is inserting into the Ignite's
cache (by checking the entries in Ignite Visor) but when querying the result
is showing empty.

Here is the code: 
from("mqtt:bar?subscribeTopicName=test&host=tcp://10.10.1.34:1883")
	.setHeader("id", new JsonPathExpression("$.id")) 
	.setHeader("firstName", new JsonPathExpression("$.firstName"))
	.setHeader(IgniteConstants.IGNITE_CACHE_KEY, new
JsonPathExpression("$.id"))
        .process(new Processor() {
		public void process(Exchange exchange)throws Exception {
				exchange.getIn().setBody( exchange.getIn().getBody(String.class));
                }
	})
        .to("ignite-cache:cache:Person?operation=PUT");

What am I missing?

[1]
https://github.com/apache/camel/blob/master/components/camel-ignite/src/test/java/org/apache/camel/component/ignite/IgniteCacheTest.java




--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Using-Camel-Ignite-for-inserting-json-object-to-Ignite-s-Cache-tp13513p13568.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Using Camel-Ignite for inserting json object to Ignite's Cache

Posted by vkulichenko <va...@gmail.com>.
Hi Austin,

I'm probably missing something, but why do you expect this to insert entry
into cache? Where did you find the syntax below?

.to("ignite-cache:cache:myCacheName?operation=PUT")

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Using-Camel-Ignite-for-inserting-json-object-to-Ignite-s-Cache-tp13513p13539.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.