It seems like gateway can't resolve application registered in eureka server using eureka.instance.appname. In our case we have applications deployed in two different environment (uat and qa) but both will register on one clustered eureka server. We differentiate the applications from two environments using eureka.instance.appname. One is registered as service_app_uat and another one as service_app_qa however the spring.application.name is service.app. Eureka is able to register the app from two different environment just fine but Spring Cloud Gateway can't resolve these two registered instances from eureka. However if we removed the eureka.instance.appname both app from two environments registered as service_app with two instances which we don't want.
Is there any other way to register application in Eureka with custom service name?
Can't you just utilize Spring Profiles and provide different naming via spring.application.name?
Related
Requirement - Is there any way via configuration/custom logic to provide a blacklist ports configuration so sprint boot service will never pick those ports when it starts, this is required as some of our legacy services runs in dedicated ports and those services starts after our spring boot application starts, if spring boot application picks those ports then it will create a clash.
example : we are looking for something like below , where we can exclude these ports so they will never be picked up by spring boot application.
exclude.ports= 18080,28080
I have an application which is running on multiple AWS hosts behind a load balancer. All of these instances load the configuration from a spring config server. I can use spring boot admin server to identify the the URL's so that I can execute the POST at hostname:port/actuator/refresh command for individual host using POSTMAN. As the number of hosts increase, it becomes difficult to run a command for each one of the hosts. Is there a way I can do the same with a single command?
We use something similar for our application
i.e Spring applications fetching properties from config server and a spring boot admin server to which all these application registers.
We have exposed an post api in bootadmin which calls refresh endpoint on all instances of specified app.
Since bootadmin has all information about registered apps, we are using it to 'publish' message to all 'subscribed' apps.
I'm specifying the config server URI spring.cloud.config.uri in the bootstrap.properties file of all my config server clients.
So is there any use of adding an #EnableDiscoveryClient annotation to it, and registering the configuration service in Eureka?
There are various use cases why registering your config server on Eureka could be useful:
Discovery-first bootstrapping
When using the Spring cloud config service, you have two choices when bootstrapping your application, as mentioned by the documentation:
Using a config-first setup (default)
Using a discovery-first setup
When you use a discovery-first setup, all applications can retrieve their configuration by looking up the URL of the configuration service on Eureka:
spring.cloud.config.discovery.enabled=true
spring.cloud.config.uri=http://config-service
In this case, the application will look for a service named config-service on Eureka, and will use the given hostname and port to connect.
Discoverability
Some tools, like Zuul, Spring boot admin, ... will automatically discover all applications and use them, for example:
Spring boot admin can be setup to automatically discover all applications to manage them.
Zuul will automatically forward all routes matching /{application-name}/** to the given application.
#EnableDiscoveryClient activates the Netflix Eureka DiscoveryClient implementation and tells it to register itself with a service registry.
So, without this annotation, your application will not able to register itself to any Registry. And hence will not be discovered from any service as well.
Edit: Registering your application to DiscoveryServer provides many benefits, some of them are below :
Application independence: When you register your application to DiscoveryServer it decouples it from another application. Doing so you don't need to hardcode the name and URL of your application in using application.
Load Balancing: Register your application to DiscoveryServer provides an effective and efficient way to provide load balancing.
Multiple instances of same application: In order to provide load balancing you can add multiple instances of a single application.
Resilience: When an instance is not working then Server can use the circuit breaker to handle requests effectively and helps in making system responsive and resilient.
I have a eureka server and some services, they register to the eureka and use a Feign to communicate with each other.
Every of such services is deployed into embedded tomcat container. Also I have some services which are executed as a demons by scheduled, they shouldn't be into tomcat container, but they also have to use a Feign to get data from some services.
By example I have a monitoring which is executed one time per day and checks some data got from another service by REST. That monitoring don't have to register in eureka cause it doesn't have api for input.
If I put #EnableFeignClients without #EnableEurekaClient, it won't work, but
if i put both of these annotations, service will be deployed into tomcat.
How could I do that without tomcat container?
I am looking for the best method to host multiple websites developed using Spring Boot.
I have a public IP and it points to EC2 machine.
Already I am running one web application on it, developed using Spring Boot.
Now, I am looking for a way to create my second Spring Boot application(running on a different port).
My configuration should result like this(Single public IP),
www.app1.com(x.x.x.x) => Spring Boot App1
www.app2.com(x.x.x.x) => Spring Boot App2
I found many articles on internet dealing with conf/server.xml file, http://tomcat.apache.org/tomcat-7.0-doc/config/host.html
Can someone help me to achieve the same
The best way is probably to use a reverse proxy front end. E.g. install nginx on your EC2 box, or (probably better if you are serious about it) use an ELB, and Route 53 to register your DNS record.