REST API: passing custom POJOs

classic Classic list List threaded Threaded
2 messages Options
captcha captcha
Reply | Threaded
Open this post in threaded view
|

REST API: passing custom POJOs

Hi Ignite Users,

For the REST API, is that possible to pass custom POJO objects? An example
use case:
Let's say I have a Person class:
class Person {
   String name;
   UUID id;
   Location location;
}
Class Location {
   long lat;
   long long;
}

Let's say I cache some Person objects in the Ignite cluster, keyed on their
UUIDs. Now I want to pass in a Location object and a List of Person UUIDs
and then return the distance between the given location and each person in
the give list.

This requires passing POJOs to and back from Ignite compute gird. Is it
possible to use the REST API to do this? If not, what's the recommended way
for this? Are there any examples I could check?

Thanks.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
akorensh akorensh
Reply | Threaded
Open this post in threaded view
|

RE: REST API: passing custom POJOs

This post was updated on .
Hi
REST can accommodate the following types:
https://apacheignite.readme.io/docs/rest-api#section-data-types

You can use  a ConnectorMessageIntercetor to intercept all incoming/outgoing
rest requests :
https://apacheignite.readme.io/docs/rest-api#section-general-configuration 

https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/configuration/ConnectorConfiguration.html#setMessageInterceptor-org.apache.ignite.configuration.ConnectorMessageInterceptor-

You can serialize your pojo before sending, and on the receiver end use
ConnectorMessageInterceptor#onReceive to de-serialize accordingly .
The interceptor also provides a way ConnectorMessageInterceptor#onSend-to
transform outgoing rest requests.

Thanks, Alex

-----Original Message-----
From: captcha <hangelwen@gmail.com> 
Sent: Thursday, October 10, 2019 4:51 PM
To: user@ignite.apache.org
Subject: REST API: passing custom POJOs

Hi Ignite Users,

For the REST API, is that possible to pass custom POJO objects? An example
use case:
Let's say I have a Person class:
class Person {
   String name;
   UUID id;
   Location location;
}
Class Location {
   long lat;
   long long;
}

Let's say I cache some Person objects in the Ignite cluster, keyed on their
UUIDs. Now I want to pass in a Location object and a List of Person UUIDs
and then return the distance between the given location and each person in
the give list.

This requires passing POJOs to and back from Ignite compute gird. Is it
possible to use the REST API to do this? If not, what's the recommended way
for this? Are there any examples I could check?

Thanks.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/