Netflix Arcaius serving as config service for multiple Spring Boot micro-services - spring-boot

I'm having a problem with how to use just Netflix Archaius to work as a config server for multiple Spring Boot microservices. Previously when I applied Eureka and Spring Cloud Config Server in my multiple-services project built with Spring Boot, each microservie would get its own .properties file from the Spring Cloud Config server through the discovery function of the Eureka service. But now I need to change the Spring Cloud Config Server into a Netflix Archaius service, from which the Spring Boot microservices will get .properties file, i have no idea about how to achieve it. Is there any good idea for my reference? Thanks in advance.

Finally I gave up using Netflix Archaius to pull properties file for microservices. Instead, I wrote down required key-value-pair properties into the application.properties of each springboot microservice. Since all the springboot microservices will be deployed in the DCOS platform in the form of docker containers, some inconstant properties were configured into the marathon deployment scripts, which could be populated into the springboot applet. In this way I managed to configure the key-value-pair properties from the outside instead of being hardcoded in the program codes.

Related

Spring Boot Actuator + Spring Boot Admin - Is there a way to define a custom management url?

Is there a way I can define the port for the management URLs (not the management.server.port) so that spring boot admin can identify the actuator URLs from the spring boot app for monitoring?
I'm running the spring boot app in a docker container and it's externally exposed on a different port using the Kubernetes NodePort.
If you are using service discovery for application lookup you could define the exposed management port in instance metadata. This metadata is used to build up the management URL.
More details documented here:
http://codecentric.github.io/spring-boot-admin/current/#spring-cloud-discovery-support
Handling is done in de.codecentric.boot.admin.server.cloud.discovery.DefaultServiceInstanceConverter
Example for Eureka:
eureka.instance.metadata-map.management.port=[K8S-EXPOSED-PORT]
If you are using Service Discovery, take a look into DefaultServiceInstanceConverter, try specifying the management.port property.
If you are not using Service Discovery, then take a look into de.codecentric.boot.admin.server.domain.values.Registration, you might need to use the builder apis to register your application correctly (try to set managementUrl properly). Note, you will need to do this in your client application (the one which is being monitored).

spring cloud config client set config url at property file

I have a spring cloud project. There are config server (config-srv), eureka server (eureka-srv) and some other service with business logic, let's call it main service (main-srv).
I'm packaging them into jars and run one by one. My apps get their properties from a file in the same directory with jars.
So, I'm setting properties to config-srv through "application-native.properties".
But if i want to change config-srv url (for example, i want http://localhost:9999), how can i share this url for all micro-services before they will boot ? I'm trying to share this url in "application-default.properties" but it makes no effect.
You can put the Spring Cloud Config server details in bootstrap.properties file in each microservices.
spring.application.name=microserviceName
spring.profiles.active=dev
spring.cloud.config.uri=http://localhost:9999
spring.cloud.config.username=your_username
spring.cloud.config.password=your_password
Go through the link to have more detail about spring cloud config
https://howtodoinjava.com/spring-cloud/spring-cloud-config-server-git/

Registering Spring Cloud Microservice with Eureka server

I am trying to create spring cloud microservices and also need to include eureka server and zuul as spring cloud tools. Now I created one module in my one spring boot project. I registered that service with eureka server. And also I created one spring boot project for adding zuul service discovery and also registered with eureka project.
Here my doubt is that When I am adding another module as another spring boot project, Can I register that application also with my current eureka server as client? What type of relation that eureka server project and microservice having? one-To-One or One-To-Many? Can I register 3 or 4 microservices with one eureka server as client?
Eureka Server will let you add as many microservices (modules of spring boot projects like you said).
From Spring Cloud landing page:
As long as Spring Cloud Netflix and Eureka Core are on the classpath
any Spring Boot application with #EnableEurekaClient will try to
contact a Eureka server on http://localhost:8761 (the default value of
eureka.client.serviceUrl.defaultZone):
That means that you can use a single eureka server for multiple microservices which are registered as clients to the eureka server.
So yes, it's a One-To-Many relationship.
You will want at one point to look into multiple Eureka servers used in load balancing, for redundancy purposes, but for now you will be fine.

Spring cloud registering multiple instances of same service

I am developing a microservice, using Spring Boot, that exposes REST Endpoint. Because of scalability, I have to run multiple instances of this services on a different port. What will be the configurations for the applications so that it can register with eureka and requests are load balanced? I am using Spring cloud config, Eureka server and zuul.
Attaching following entries in the client properties file will do the trick. This is for Spring cloud config dalston
eureka.instance.instanceId=${spring.application.name}:${spri‌​ng.application.insta‌​nce_id:${random.valu‌​e}}
I guess you meant to register with Eureka instead of Config server.
To register multiple instances that might be running in the same host but listening on a different port you would need to set eureka.instance.metadataMap.instanceId to a unique value maybe using:
eureka.instance.metadataMap.instanceId=${spring.application.name}:${random.int}

Consuming Spring cloud config using Spring REST service (non-boot rest service)

I'm just curious, is it possible to consume Spring Cloud config by a Spring REST service which is not a Spring boot application. If it is possible, where to define the properties in a Spring REST service. I meant, where should I define
spring.cloud.config.uri etc.
Or, only Spring boot applications are allowed to consume Cloud configuration?
Any thought would be appreciated. Thanks
well spring boot just bootstrap all configuration automatically . so for simple spring application you have to config it manually and define the cloud config server beans in your application configuration file . it could be pure old fashion xml files or just using java code configuration with #Configuration. you could find some samples in github

Resources