Issue with using Ignite with Spring Data

classic Classic list List threaded Threaded
4 messages Options
p.srikanta p.srikanta
Reply | Threaded
Open this post in threaded view
|

Issue with using Ignite with Spring Data

I'm trying to integrate a Spring data project (without JPA) with Ignite and struggling to understand some basic traits. Would be very helpful if you can share some insights on the issue I'm facing.

Currently the cache has been defined as below with the client node, this config is not present in the server node, gets created when the client node joins the cluster. The repositories are detected during the instantiation of the Spring Boot application. 

All the documentation including the official example repo of the Apache Ignite does not pass in the data source but instead cachConfig is set with the IndexedTypes.

Question: Where should I pass on the DataSource object ? Should I create a CacheJdbcPojoStoreFactory and pass on the dataSource ?  


Thanks,
Srikanta
dmagda dmagda
Reply | Threaded
Open this post in threaded view
|

Re: Issue with using Ignite with Spring Data

Hi Srikanta,

You forgot to share the configuration. Anyway, I think it's clear what you are looking for.

Check this example showing how to configure CacheJdbcPojoStoreFactory programmatically (click on the "Java" tab, by default the example shows the XML version):

Also, if you need to import an existing schema of a relational database and turn it into the CacheJdbcPojoStore config, then this feature of Web Console can be helpful: 

Finally, keep an eye on this Spring Data + Ignite tutorial that covers other areas of the integration. You might have other questions and issue going forward and the tutorial can help to address them quickly:

-
Denis


On Fri, Aug 21, 2020 at 9:09 AM Srikanta Patanjali <[hidden email]> wrote:
I'm trying to integrate a Spring data project (without JPA) with Ignite and struggling to understand some basic traits. Would be very helpful if you can share some insights on the issue I'm facing.

Currently the cache has been defined as below with the client node, this config is not present in the server node, gets created when the client node joins the cluster. The repositories are detected during the instantiation of the Spring Boot application. 

All the documentation including the official example repo of the Apache Ignite does not pass in the data source but instead cachConfig is set with the IndexedTypes.

Question: Where should I pass on the DataSource object ? Should I create a CacheJdbcPojoStoreFactory and pass on the dataSource ?  


Thanks,
Srikanta
p.srikanta p.srikanta
Reply | Threaded
Open this post in threaded view
|

Re: Issue with using Ignite with Spring Data

Hi Denis,

Thanks for taking time to reply and sharing those links. I can confirm to you that I've read through them before and have been following them as well. 

However as I read them again, I realised that it was anyway necessary to load the cache before executing the SELECT sql queries on top of a cache, now, would this hold true in the case of Spring Data as well ? (Very likely yes, but want to get the confirmation) If so, then are we expected to preload the cache on start up and only after that will the read-through property kick in to add the entries into the cache for the ones which are missing ?

If my above understanding is correct then that explains why I was getting null results from the queries executed once the Spring boot is instantiated as the cache load on startup was not complete yet.


Regards,
Srikanta

On Fri, Aug 21, 2020 at 6:47 PM Denis Magda <[hidden email]> wrote:
Hi Srikanta,

You forgot to share the configuration. Anyway, I think it's clear what you are looking for.

Check this example showing how to configure CacheJdbcPojoStoreFactory programmatically (click on the "Java" tab, by default the example shows the XML version):

Also, if you need to import an existing schema of a relational database and turn it into the CacheJdbcPojoStore config, then this feature of Web Console can be helpful: 

Finally, keep an eye on this Spring Data + Ignite tutorial that covers other areas of the integration. You might have other questions and issue going forward and the tutorial can help to address them quickly:

-
Denis


On Fri, Aug 21, 2020 at 9:09 AM Srikanta Patanjali <[hidden email]> wrote:
I'm trying to integrate a Spring data project (without JPA) with Ignite and struggling to understand some basic traits. Would be very helpful if you can share some insights on the issue I'm facing.

Currently the cache has been defined as below with the client node, this config is not present in the server node, gets created when the client node joins the cluster. The repositories are detected during the instantiation of the Spring Boot application. 

All the documentation including the official example repo of the Apache Ignite does not pass in the data source but instead cachConfig is set with the IndexedTypes.

Question: Where should I pass on the DataSource object ? Should I create a CacheJdbcPojoStoreFactory and pass on the dataSource ?  


Thanks,
Srikanta
dmagda dmagda
Reply | Threaded
Open this post in threaded view
|

Re: Issue with using Ignite with Spring Data

However as I read them again, I realised that it was anyway necessary to load the cache before executing the SELECT sql queries on top of a cache, now, would this hold true in the case of Spring Data as well ? (Very likely yes, but want to get the confirmation) If so, then are we expected to preload the cache on start up and only after that will the read-through property kick in to add the entries into the cache for the ones which are missing ?

You got it right. If your records are stored in an external database, then you have to pre-load them in Ignite first before using Ignite SQL. The latter reads records from disk only if those are stored in Ignite persistence. Ignite SQL can't query external databases.

Ignite can pre-load a missing record from an external database only if the record is requested via key-value APIs. With those APIs, it's all trivial - if Ignite doesn't find the record in its memory storage then it will create an external-database-specific query to load the record from the external db. SQL is much more complicated.

-
Denis


On Fri, Aug 21, 2020 at 1:51 PM Srikanta Patanjali <[hidden email]> wrote:
Hi Denis,

Thanks for taking time to reply and sharing those links. I can confirm to you that I've read through them before and have been following them as well. 

However as I read them again, I realised that it was anyway necessary to load the cache before executing the SELECT sql queries on top of a cache, now, would this hold true in the case of Spring Data as well ? (Very likely yes, but want to get the confirmation) If so, then are we expected to preload the cache on start up and only after that will the read-through property kick in to add the entries into the cache for the ones which are missing ?

If my above understanding is correct then that explains why I was getting null results from the queries executed once the Spring boot is instantiated as the cache load on startup was not complete yet.


Regards,
Srikanta

On Fri, Aug 21, 2020 at 6:47 PM Denis Magda <[hidden email]> wrote:
Hi Srikanta,

You forgot to share the configuration. Anyway, I think it's clear what you are looking for.

Check this example showing how to configure CacheJdbcPojoStoreFactory programmatically (click on the "Java" tab, by default the example shows the XML version):

Also, if you need to import an existing schema of a relational database and turn it into the CacheJdbcPojoStore config, then this feature of Web Console can be helpful: 

Finally, keep an eye on this Spring Data + Ignite tutorial that covers other areas of the integration. You might have other questions and issue going forward and the tutorial can help to address them quickly:

-
Denis


On Fri, Aug 21, 2020 at 9:09 AM Srikanta Patanjali <[hidden email]> wrote:
I'm trying to integrate a Spring data project (without JPA) with Ignite and struggling to understand some basic traits. Would be very helpful if you can share some insights on the issue I'm facing.

Currently the cache has been defined as below with the client node, this config is not present in the server node, gets created when the client node joins the cluster. The repositories are detected during the instantiation of the Spring Boot application. 

All the documentation including the official example repo of the Apache Ignite does not pass in the data source but instead cachConfig is set with the IndexedTypes.

Question: Where should I pass on the DataSource object ? Should I create a CacheJdbcPojoStoreFactory and pass on the dataSource ?  


Thanks,
Srikanta