I would like to know how I can programmatically find the netty port while a spring boot 2 + spring cloud Finchley application is starting up?
I am running the service in a docker container on AWS in EC2 container service - I therefore set server.port=0, and cannot use this property to find the actual port used.
In spring-boot 2 you can use #LocalServerPort to wire the dynamic port used
https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/web/server/LocalServerPort.html
Related
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).
Here're my case:
I'll use webflux starter and the default reactor netty server to serve my webflux app via 8080.
I'll use an embedded tomcat to serve my internal admin app which is servlet based, say on 7070.
Does spring boot support this by simply applying some properties settings?
I just checked:
If I have both starter-webflux and starter-tomcat, the tomcat will win at 8080.
If I change server.port = 7070, tomcat will start at 7070 and netty is still ignored.
Thanks
Leon
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
I have a Spring Boot services and I manage deployment on the server using a batch script. So, when ever I have to deploy a update I shutdown current running service using Spring Boot's shutdown hook. For example:
curl -X POST http://%HOST_NAME%:%PORT%/actuator/shutdown
Here I am giving %PORT% number of the service, Which is same as I have given in application.yml. I don't want hardcode the port neither in application.yml nor want to pass from the command line while starting the Spring Boot application. Actually I do not want to mention the port. I just want Spring Boot use any of the random port available on the server. If I will do the same then how can I shut down the service because I don't know the port where the service is running.
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}:${spring.application.instance_id:${random.value}}
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}