I am working on some new custom distributed objects to run in Hazelcast SPI.
As can be seen in : http://docs.hazelcast.org/docs/latest/manual/html/spiaddproperties.html you can enable via the Hazelcast xml config, or of course, you can enable programmatically.
It appears that the spring hazelcast xml schema does not support SPI creation, and I would like to create/enable and inject spring beans as properties to the new service.
Can anyone advise if this is possible? I want to utilize spring to instantiate the hazelcast instance as this is the most robust way I've found to do so in a large application.
I think it is supported.
You can find an example here: https://github.com/hazelcast/hazelcast/blob/master/hazelcast-spring/src/test/resources/com/hazelcast/spring/fullcacheconfig-applicationContext-hazelcast.xml#L309
Related
I want to use spring boot with caching data retrieved from rest web service.
I propose to use redis for caching data. Is it possible to use embeded redis with spring boot without installing a redis software?
If yes with which version of spring boot and how to do it?
Thanks for your responses.
Redis can't meet your request.
You can of course simply use embedded EhCache within your Spring Boot application. If you want to share the cache, it depends on your architecture. You could expose REST endpoints to make you cache available to other applications.
You can refer: https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-cache.
Spring have annotation #EnableCaching to enable or disable cache. Also, there are four annotations like #Cacheable and #CacheEvict to custom the cache logic.
Hazelcast supports the scenario you are trying to implement. It has a concept of embedded cache that can be shared/synchronized across the service nodes.
For more details see:
https://reflectoring.io/spring-boot-cache/
https://hazelcast.com/blog/how-to-use-embedded-hazelcast-on-kubernetes/
I'm using spring cloud to connect to my Kafka broker. It works fine. Now I want to create my binding by code instead of annotation.
Is there a convenient way to do it?
Could you elaborate why do you want to do the binding programmatically instead of using #EnableBinding.
While Spring Cloud Stream simplifies exactly that, if you prefer to use your own way of connecting (for any other specific reason), then you might want to check the Spring Integration adapters to do the binding. But, in this case, you are on your own by setting up the lifecycle and all other goodies that Spring Cloud Stream provides.
If you still want to use Spring Cloud Stream but don't want to use the annotation, then check here to see all the configuration that Spring Cloud Stream does when you annotate and apply your use case.
Please follow https://github.com/spring-cloud/spring-cloud-stream/issues/954. We plan to add this feature to 1.3.0.RC1.
I am trying to connect to Cassandra from my Spring boot application using spring-boot-data-cassandra.I have two doubts.
1) Is it recommended to use the CassandraAutoConfiguration i.e. by providing all Cassandra configurations in application.properties with prefix(spring.data.cassandra.*) so that my app will create a cluster for me or do I need to manually create cluster bean, because in CassandraAutoConfiguration cluster bean is annotated with #ConditionalOnMissingBeanso which one is more preferred to use spring cassandra auto configuration or manually creating a cluster bean.
2) My cluster is enabled with ssl at Cassandra side. So when I am auto configuring Cassandra connections with ssl enabled (by setting spring.data.cassandra.ssl=true) then Default SSL context is created for me, but i need to provide my truststore path and truststore password to initialize SSLContext. There is no properties provided at data-cassandra like the one provided for kafka(spring.kafka.ssl.truststore-location= # Location of the trust store file.
spring.kafka.ssl.truststore-password= # Store password for the trust store file.), so is there any way to provide truststore file location and password to AutoConfigure my Cassandra configuration or to override default SSLContext created.
Please help me and correct me if my understanding is wrong. Thanks.
Updates:
https://github.com/spring-projects/spring-boot/issues/8476
Using Spring Boot's Auto-Configuration is the preferred approach but Boot goes out of your way if you need to apply a more specific configuration. Most conditional beans are created if there's no other provided #Bean.
If you provide Cluster yourself, then Spring Boot's Auto-Configuration will not provide a second Cluster bean.
The preferred approach since Spring Boot 1.5, if you need a more specific configuration, is providing a ClusterBuilderCustomizer bean that gets called to customize Cluster.Builder to your needs.
You might also want to file an issue in Spring Boot's issue tracker. Specific SSL configuration is a common configuration use-case.
The presence of a second datasource in a spring boot application is failing caching with the exception:
java.lang.IllegalArgumentException: Cannot find cache named 'entity-name' for CacheEvictOperation
With one datasource it's working.
Both the datasource is auto-configured by spring boot.
Datasource one using mysql, declared as primary
Datasource two using mongodb
Is this a known case? Do I need to explicitly configure entity and transaction managers?
Spring Boot does not support auto-configuring more than one datasources for general purposes so you may want to revisit your configuration (or the description).
Yes, you need to configure the entity manager and transaction managers explicitly when you need to use more than one datasource.
Hopefully, this sample shows you how to do it.
We are planning to move a Spring based application to Cloud Foundry.
The application currently uses WAS server and access data sources using JNDI lookup.
We are using spring features like MVC, AOP etc.
I have certain questions in mind :
Is it possible to switch to Tomcat and configure dataSources using Spring-cloud-connectors and possible conflicts we might run into ?
Currently , datasources are configured in XML files, Should I use the same XML files or switch to annotations.
Can anyone please provide some clarity over this and other known issues with this approach?
Spring Cloud Connectors are by far the easiest way to bind to data sources in Cloud Foundry. I would recommend converting your JNDI lookups to use these service connections as described here:
http://docs.cloudfoundry.org/buildpacks/java/spring-service-bindings.html
cloud foundry automatically reconfigures your datasource when it find a database service attached the cloud app. its super coooool....