Existing Spring Application to Cloud Foundry - spring

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

Related

Azure Blob Storage - Spring starter or Apache Camel

I am using Azure Blob storage for one my microservices. We have a spring boot microservice which I would like to get it triggered every time a a file is uploaded to the blob. I see that apache camel also has a component which supports producer as well as consumer for azure blob storage. What is the difference between spring boot starter for azure blob and apache camel component for the same. I see that I have to write very less code with apache camel. Is there any drawback for using the same.
The camel-azure-storage-blob-starter has a dependency on camel-azure-storage-blob camel-component and provides spring-boot configuration classes to configure the camel component.
If your runtime is spring-boot, you should use the org.apache.camel.springboot:camel-*-starter dependencies.
There is an examples repository for using Camel on Spring-Boot - there is no example for azure-storage-blob, but you can take a look at other components, the bootstrap should be pretty similar.

Can Spring Cloud Stream work with Spring Cloud Kubernetes?

I haven't seen any example of combining the two, even though it makes sense they'll work together (because of being both subprojects of Spring Cloud). I want to use Spring Cloud Stream (Reactive Processing) for reading from Kafka and writing to MongoDB with the Reactive Mongo driver. Can I use Spring Cloud Config and Spring Cloud Kubernetes for a remote git configuration server, even though the application is an event-driven application and not a requests-based API?
It's pretty unclear how to plug these Kubernetes and config projects into Spring Cloud Stream, and in general, it's unclear to me if all of the other Spring Cloud projects can work with Spring Cloud Stream reactively. For instance, I couldn't also find a reference for using Spring Cloud Sleuth & Zipkin with Spring Cloud Stream. Can someone make it clearer for me and reference code examples if exists?

Netflix Archaius with Spring Cloud Config server

I followed this documentation for Archaius and some other online articles. However, presumably, each service should have Archaius or configuration related codes/dependencies(-jars) to load configuration values. My concern is that if a change is required in loading configuration, then each service has to be reloaded/redeployed.
Q1. Can anyone let me know how to keep a centralized Archaius configuration service so that client services pull configurations.
On the contrary, Spring Cloud Config server does that job - all configurations are in one place. But I feel that it lacks loading configurations from a custom resource - data loads from a database as Archaius provides, for example.
Q2. Is there a work around to make Config Server loads configurations from Archaius ?
For Q1, you should look at the 2.x branch of Archaius, specifically https://github.com/Netflix/archaius/blob/2.x/archaius2-persisted2/src/main/java/com/netflix/archaius/persisted2/Persisted2ConfigProvider.java. This is configured to make a rest call to some service which will front your Config. At Netflix, we have a rest service backed by Cassandra. Naturally, you can back that with whatever you would like. But fair warning, this Archaius setup was made for Guice and requires a bit of manual setup. It is not quite as seamless as you might expect if you've been working with Spring Boot/Cloud starters for example.
For Q2, Spring Cloud Config does indeed support loading data from a DB. Also, in my experience with the Spring products, they are almost always quite easy to extend to your own purposes if you'd like to do something more custom.
General suggestion: If you have no other need/use of Archaius aside from remote config and you are a Spring user, I'd suggest just going with Spring Cloud. It would be far easier to configure and probably serve your requirements just fine.
Archaius provides a way to deal with reading dynamically changing Config with minimal performance impact. If you're not in Spring, or happen to need fast access to dynamic properties, consider Archaius.

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

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

Spring Cloud Netflix - how to access Eureka/Ribbon from traditional web app?

Everything I found on the internet about Spring Cloud Netflix is about running microservices from Boot applications using #EnableEurekaClients and so on.
Now I'm trying to connect my logging microservice within a traditional war application (springmvc, jaxws etc) - piece of legacy which can not be converted to Boot or modified in any way (by technical task).
I've created a new maven module "log-server-client" that knows nothing about upper web layer and intended to be used as a simple dependency in any maven project.
How should I configure access to Spring Cloud Netflix for this simple dependency? At least, how to configure Eureka and Ribbon?
I just extracted some lines of code from RestTemplate and created my custom JmsTemplate (microservice works with jms remoting with apache camel and activemq), exactly how it is done in RestTemplate, but this code stil lacks connection to infrastructure
afaik, we can create a global singleton bean, run a separate thread from this bean, and run Boot app from this thread, but don't you think that it is very ugly and can lead to problems? How it really should be used?
Great question!
One approach is to use a "sidecar". This seems to be a companion Spring Boot application that registers with the Eureka Server on behalf of your traditional web app.
See e.g.:
http://www.java-allandsundry.com/2015/09/spring-cloud-sidecar.html
http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html#_polyglot_support_with_sidecar
Another approach is to use the following library:
"A small lib to allow registration of legacy applications in Eureka service discovery."
https://github.com/sawano/eureka-legacy-registrar
This library can be used outside of Spring Boot.

Resources