Cofigure FeignClient When Target Application is configured with server.servlet.context-path - microservices

I want to consume the Other Application API's registered with Eureka Server ,
Configured it properties file like this
server.servlet.context-path=/nrdms
spring.application.name=Client2
eureka.client.serviceUrl.defaultZone=${DISCOVERY_URL:http://localhost:1000}/eureka
When I tried to consume the resources from CLient1 Application With the help of FeignClient, response is coming 404,
I configured feign client like this:-
#FeignClient(name="Client2 ")
But however If I remove server.servlet.context-path=/nrdms , It works perfectly fine.
Is it any other way If We dont like feignclient to configure without URL.

Related

Spring Cloud Config Server on Pivotal Cloud Foundry

I have two microservices. A Spring Cloud Config Server and another module that implements Spring Cloud Config Client. When I use the default configuration for the Spring Cloud Config Server service (localhost:8888) I can start it locally without any issues, after which I can start my other module as well, using a bootstrap.yml, it clearly finds the Config Server, fetches its properties and starts properly. All good. Now I'd like to push both of these services to Pivotal Cloud Foundry.
The Config Server service works just fine, service is up and running in my Space, and using the browser I can verify that it can still fetch the property files from the specific GitHub repository.
The problem is the other module, the client. I've replaced the default localhost:8888 in its bootstrap.yml file (spring.cloud.config.url parameter) to the now active service in the cloud using the Route bound to it and tried to start it locally. Unfortunately now it simply timeouts during startup. At this point I tried to specify longer timeouts but nothing helps.
Interesting thing is that if I directly copy the URL from the logs that timeouts I see it works properly in the browser locally. So why not in IntelliJ when I try to package the client with the changed parameter?
Sorry, I can't include much details here, but I hope maybe there is a straightforward solution that I've missed. Thanks!

How do I forward requests from a client to a Windows Service running on Windows Server

I have an Angular application deployed to/via IIS. This app is sending requests to REST endpoints exposed by a Spring Boot application which I am running as a Windows Service (The Spring Boot application is accessing a MongoDB but this should not be relevant, I think). The exposed REST interface is accessable via port 8080 on the servers localhost.
The Angular app is accessible as it should be but there seems to be a problem when the web app tries to access the Spring Application's REST interfaces. More specific: The client seems to be receiving HTML documents when he should be receiving JSON files.
I am new to working with IIS so beginner errors are not unlikely. I'm happy to share more information if needed!
Edit: I read again the question, and understood something wrong:
Looks like you were sending requests to your Angular server. For development you should use the embedded web server (https://docs.spring.io/spring-boot/docs/current/reference/html/howto-embedded-web-servers.html) in order to ease your server configuration steps. And from within the windows server, send request to localhost:springboot_port.
Once you want your service to be available for an external client, and to keep your service available/awake (something similar to systemd in Linux), you could try this: https://www.baeldung.com/spring-boot-app-as-a-service

Use zuul to deliver static content

I have a Zuul reverse proxy in front of my spring boot microservices, used as an API gateway.
Can the Zuul spring boot app be used to deliver static content, IE client code that calls the API gateway? I dont want to host this in a microservices or have another VM to manage for hosting content
I tried having a static folder in resources folder, but cant figure out how to map this in the application.yml responsible for routing. I dont want to route it to a NGnix or apache server, but use the embedded Tomcat of Zuul Spring boot app.
What would be the route to put in the route config, or what is the best approach for this.
Thank you
You don't have to map it in the routes config. Whatever you put in the resources/static folder will be served, as long nothing else is mapped on the same path.

Spring cloud config client without Eureka, Ribbon and spring boot

I have spring web application (not spring boot) running in AWS. I am trying to create centralized configuration server. How to refresh the spring-cloud-client after the changing the properties? As per tutorial
Actuator endpoint by sending an empty HTTP POST to the client’s refresh endpoint, http://localhost:8080/refresh, and then confirm it worked by reviewing the http://localhost:8080/message endpoint.
But my aws Ec2 instances are behind the loadbalancer so i can't invoke the client url. I didn't understand the netflix Eureka and Ribbon much but it seems like adding another level of load balancer in the client side. I don't like this approach. Just to change a property i don't want to make the existing project unnecessarily complex. Is there any other way? or Am I misunderstood Eureka/Ribbon usage?
I have looked at the spring-cloud-config-client-without-spring-boot, spring-cloud-config-client-without-auto-configuration none of them have answer. First thread was answered in 2015. Wondering is there any update?
To get the configuration properties from a config server. You can do a http request. Example:
From the documentation we can see:
/{application}/{profile}[/{label}]
/{application}-{profile}.yml <- example
/{label}/{application}-{profile}.yml
/{application}-{profile}.properties
/{label}/{application}-{profile}.properties
So if you would do a request to http://localhost:8080/applicationName-activeProfile.yml you would receive the properties in .yml format for the application with that name and active profile. Spring boot config clients would automatically provide these values but you will have to provide em manually.
You don't need Eureka/Ribbon for this to work, it's a separate component.
More info: http://cloud.spring.io/spring-cloud-static/spring-cloud.html#_spring_cloud_config
Maybe you could even use spring-cloud-config but I'm not sure what extra configuration is needed without spring-boot.
https://cloud.spring.io/spring-cloud-config/

Spring Cloud Sidecar is not working as expected

Based on the documentation, the #EnableSidecar annotation acts as a proxy for non-JVM applications that wish to register in Eureka. Accordingly, the configuration to be set is:
sidecar:
port: 81 <-- Port of the non-JVM application
health-uri: http://10.135.16.50:${sidecar.port}/api/health.php <-- URI of the non-JVM application's health endpoint
home-page-uri: http://10.135.16.50:${sidecar.port}/
Once the "sidecar" is up and running, we should be able to invoke one of the non-JVM endpoints through the service registry just by using the name that the "sidecar" application used to register in Eureka. So for example, if our "sidecar" application was registered in Eureka as "php-sidecar" to proxy a PHP application with an endpoint such as:
http://10.135.16.50:81/api/microservice.php
Then we should be able to invoke the following endpoint to get to the non-JVM application (assuming "sidecar" is in "localhost" and port 8080):
http://localhost:8080/php-sidecar/api/microservice.php
However, this is not working as expected. When we request the URI just above, a request to "localhost:81" is actually issued, because somehow the "sidecar" is picking up its host URI and not the home-page-uri defined as part of the sidecar's properties.
If we run the non-JVM application locally using localhost, then everything works as expected, but this is definitively not the realistic use case.
Therefore, what am I missing in my configuration to tell Spring Cloud (Zuul in this particular case) to use the non-JVM home-page-uri and not my local host URI?
Thanks for your support.
After some research, it turns out that the sidecar must always be deployed in the same host as the non-JVM application.
After some research, it turns out that the sidecar must always be deployed in the same host as the non-JVM application.
No, You can add sidecar.ip-address = 10.135.16.50 to your yaml config file
I'm using spring-boot-starter-parent version is 1.5.6.RELEASE
working fine

Resources