Closed aivans closed 6 years ago
It worked when adding this code to a configuration class. The idea is to have the ZuulProperties
bean with @RefreshScope
@Bean(name="zuul.CONFIGURATION_PROPERTIES")
@RefreshScope
@ConfigurationProperties("zuul")
public ZuulProperties zuulProperties() {
return new ZuulProperties();
}
Hi
I followed your comment about ZuulProperites. Are you trying to say with the changes you mentioned in the comments the routes gets deleted dynamically?
I tried with the following code but to no effect, by routes are not getting deleted dynamically. I do see the log after I deleted route2
2016-03-01 00:48:12.648 INFO 8900 --- [MOQVri6LhXrwQ-1] o.s.cloud.bus.event.RefreshListener : Received remote refresh request. Keys refreshed [spring.cloud.client.hostname, zuul.routes.route2.url, zuul.routes.route2.path]
Before:
zuul:
ignoredServices: "*"
routes:
route2:
path: /r2
url: https://api.github.com/users/rohitghatol/repos
route3:
path: /r3
url: https://api.github.com/users/rohitghatol/repos
After:
zuul:
ignoredServices: "*"
routes:
route3:
path: /r3
url: https://api.github.com/users/rohitghatol/repos
@SpringBootApplication
@EnableAutoConfiguration
@EnableZuulProxy
@EnableConfigurationProperties({ZuulProperties.class})
public class ApiGatewayServiceApplication {
@Bean(name = "zuul.CONFIGURATION_PROPERTIES")
@RefreshScope
@ConfigurationProperties("zuul")
public ZuulProperties zuulProperties() {
System.out.println("======> Called");
return new ZuulProperties();
}
public static void main(String[] args) {
SpringApplication.run(ApiGatewayServiceApplication.class, args);
}
}
Also I don't see ======> Called
getting printed, so looks like my ZuulProperties bean is not getting called.
@rohitghatol I have to remember what I did. Too many things happened since I tested.
can you try to initialize zuulProperties()
in a different Configuration
class?:
@Configuration
public class ApiGatewayConfiguration {
@Bean(name="zuul.CONFIGURATION_PROPERTIES")
@RefreshScope
@ConfigurationProperties("zuul")
public ZuulProperties zuulProperties() {
return new ZuulProperties();
}
}
@aivans The above code worked for me! Thanks for sharing.
@freedombird9 welcome
@aivans can you offer a demo in github,my local app can't work
APPLICATION FAILED TO START
Description:
Field zuulProperties in org.springframework.cloud.netflix.zuul.ZuulConfiguration required a single bean, but 2 were found:
Action:
Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed
@Syy0n that had nothing to do with this issue
Hi All,
I used Zuul to implement gateway for single service is working fine. I want to update some parameter in zuul property dynamically. here is my application.properties .Please advice. Thanks
zuul.routes.Myform.path=/MyApp/form/api/v1/{CountryCode}/forms/** zuul.routes.Myform.url=http://${server.ip}:Prort/MyApp/form/api/v1/{CountryCode}/forms
@spencergibb zuul.routes.Myform.path=/MyApp/form/api/v1/{CountryCode}/forms/** zuul.routes.Myform.url=http://${server.ip}:Prort/MyApp/form/api/v1/{CountryCode}/forms
Can we do this? Is this feature got implemented?
The issue is still open so this feature has not been implemented
Can you please share, How we need to configure the routes in spring cloud config to get update it in gateway dynamically? I am using spring cloud config with JDBC backend.
My requirement is, I want to add/update the routes dynamically using spring cloud config. (I have spring cloud config with JDBC backend and API Gateway with zuul) Please help.
@ghoddg your question is different please open a separate issue, or post a question on StackOverflow, or reach out to us on Gitter.
Use the workaround suggested by @aivans
I noticed that it is possible to edit routes via Spring cloud Config (or by changing the yml directly) with the same type
url
, but it is not possible to change the route to point to a service VIPScenario:
url