how to connect with gemfire running on local machine using spring data gemfire with annoatations - spring

I have tried so many demos but I am not able to create region on my local gemfire .
my code is running in embedded mode but I want to run it as client server mode with using annotions how should I do this.
Thanks.

Your problem description is pretty vague.
You should have a look at my pivotal-gemfire-clientserver-examples that compares and contrasts using native GemFire configuration (both cache.xml and then using GemFire's Java API) vs. Spring configuration (again using both Spring XML as well as Spring Java configuration meta-data).
For instance, you can see here that I configured and bootstrapped a GemFire Server using Spring Boot along with a Java configuration class. The GemFire cache client is my test class (along with the client-side Java config), but easily could have been another standalone, Spring Boot application.
Another, interesting tidbit, is that you can connect to the Spring Boot, GemFire Server application using Gfsh once the server is up and running. To connect in gfsh, use...
gfsh>connect --jmx-manager=localhost[1199]
Hope this helps!
-John

Related

How to setup Tomcat Session Replication with Spring Boot embedded tomcat

I haven't been able to find any guide on how to programmatically setup tomcat session replication when using an embedded tomcat with spring boot. It was even a hard time finding out about the "tomcat-catalina-ha" dependency.
I have a working Tomcat session replication example working when setup on a non-embedded tomcat, but converting it over to Java config hasn't been working. I looked into Hazelcast, but a few of the options I need require the enterprise license. I've also been told that storing sessions in a traditional database doesn't scale well.
I'm looking for a guide or example project that implements Tomcat session replication using an embedded tomcat. Barring that, I'd be interested in why there are no guides in the first place?

Hazelcast +Sring Boot + Kubernetes - How to setup Client-Server topology

I'm trying to see how to configure Client-Server with my Spring Boot application using Hazelcast on Kubernete, since we want to have the capability of sharing the cache between different Spring Boot applications (I'm already able to setup the Embedded distributed cache with Kubernetes - which is not what we need).
In case of Spring Boot single application(not on Kubernetes), its kind of easy where i will spin up a Server lets say with 'localhost' and also spin up the client connecting to localhost. Also i can have multiple instances(members) of Server which will form a Hazelcast Cluster.
However in case of Kubernetes, I know we need to have 2 different Spring Boot applications, one will act as a Server and others will be client accessing the cache, but want to know how the client would connect to the Server. Because in case of Spring we Autowire the HazelcastInstance, so how would i connect to the Server which is running in its own Kubernetes Pod ( and container).
There are a few deployment guides for Kubernetes here, and worked examples here & here.
If your server pods are joining, then you pretty much have it. A client uses the same discovery mechanism.
Add the hazelcast-kubernetes plugin to the client's pod, and set the configuration properties with the same values as you use on the server for namespace, dns, etc.
Thanks Neil. As you indicated its the same way i currently configured in embedded caching on Kubernetes. I'am using the Service-Name and namespace to discover and connect to the Server members from HazelcastClient instance.
This is from Client Spring Boot application's HazelcastConfiguration:
#Bean
public HazelcastInstance hazelcastInstance() {
final ClientConfig config = new ClientConfig();
config.setClusterName("cluster-name");
if (enableOnK8s) {
config.getNetworkConfig().getKubernetesConfig().setEnabled(true)
.setProperty("namespace", namespaceValue)
.setProperty("service-name", serviceName);
}
return HazelcastClient.newHazelcastClient(config);
}
And on Hazelcast Server Spring Boot application, configuration stays same as Embedded Hazelcast configuration.

Will apache Ignite identify the current host and port of webservice it is used in by itself?

What kind of configuration should be used to make the apache ignite used in a restful webservice to identify itself the host and port wherever it is deployed.
I could see directly giving host and port name in the example-ignite.xml file.
Ignite doesn't know whether it's in web service or not. You need to configure your own web service, for example, using jetty + jersey and call Ignite API from it when it's needed:
Ignite Spring Boot integration example, Spring Boot REST service example
Ignite also comes with it's own REST API:
https://apacheignite.readme.io/docs/rest-api

Existing Spring Application to Cloud Foundry

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....

With Spring do you still need a java application server and when?

looks to me you need tomcat or some other servlet engine for the web part.
what about data access part using hibernate and jms? Thanks.
No, you don't need an application server, you can see Spring as a proprietary, modular application server implementation / adapter. But you still need an a servlet container.
Data access part: you can use hibernate and some standalone connection pool
jms: Spring is not a JMS provider, but it nicely integrates POJOs with any JMS provider
Spring also has comprehensive transactions support
Finally you have jmx and aop support built-in and easy integration with bean validation, jpa, web services, rmi, jci, task scheduling, caching...
As you can see you can either use certified application server and Java EE stack or built on top of Tomcat and pick Spring modules you need. Sometimes Spring uses standard Java EE APIs (like JPA), more often it builts its own.

Resources