These are chat archives for spring-cloud/spring-cloud

23rd
Aug 2016
Jeremy Mefford
@jeremymefford
Aug 23 2016 17:44

I have a simple question about Consul and services. Is there a way that i can reference a service and port in .yml from the consul service registry? for instance, say i have this service defined:

{"service": {"name": "webdb", "address": "8.8.8.8", "tags": ["oracledb"], "port": 1527}}

in my application.yml how can i reference the host and port of that consul registered service?

Dave Syer
@dsyer
Aug 23 2016 17:46
I don't think you can
Or maybe you can if you are using consul for configuration. But not if it's a service definition.
(Service discovery comes after application.yml is parsed)
Jeremy Mefford
@jeremymefford
Aug 23 2016 17:51

I am using it with both @EnableDiscoveryClient and @EnableConfigClient, i'm pulling the application.yml from consul (using git2consul to push the whole file up). I'm trying to figure out how to make this oracle conn string more env. agnostic

jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = <my_db_host>)(PORT = <my_db_port>))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = web)))

would love to do this:

jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = ${consul.services.webdb.address})(PORT = ${consul.services.webdb.port}))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = web)))
Dave Syer
@dsyer
Aug 23 2016 17:53
In this case it seems more like configuration than service registration
You could move your properties to config and consume them however you feel
Jeremy Mefford
@jeremymefford
Aug 23 2016 17:57
@dsyer i am attempting to move from a coded DataSource (where i could pull from the service registry) to a declarative tomcat conn pool setup, that is why i was really hoping to grab the IP from consul as i'm pulling in configs. i hope that makes sense
Spencer Gibb
@spencergibb
Aug 23 2016 17:58
@dsyer @jeremymefford no you can’t currently
bitsofinfo
@bitsofinfo
Aug 23 2016 19:34
Ryan Baxter
@ryanjbaxter
Aug 23 2016 19:38
@bitsofinfo I have not noticed that
is it reproducible every time?
bitsofinfo
@bitsofinfo
Aug 23 2016 19:39
with this app yes, after a restart, the first 1-2 invocations of a feignclient to these endpoints behave like this
Ryan Baxter
@ryanjbaxter
Aug 23 2016 19:41
so only with that app, or have you observed it as a general behavior?
bitsofinfo
@bitsofinfo
Aug 23 2016 19:43
only w/ this app talking to this one other endpoint. The target endpoint is up, returns 200 and sends back data, but that seems to occur after this hystrix breaker executes the fallback. I've yet to step into all of it w/ a debugger
Ryan Baxter
@ryanjbaxter
Aug 23 2016 19:45
could be a hystrix timeout
have you tried increasing the timeout?
bitsofinfo
@bitsofinfo
Aug 23 2016 19:46
the thing is, this occurs in under 1-2 seconds
Ryan Baxter
@ryanjbaxter
Aug 23 2016 19:46
you might want to give it a shot though
bitsofinfo
@bitsofinfo
Aug 23 2016 19:46
its like immediate (see log above). Request is sent, ribbon LB initialization log entries, fallback tripped. 200 response comes back
Ryan Baxter
@ryanjbaxter
Aug 23 2016 19:46
either try disabling hystrix for feign or give it a bigger timeout
maybe its the initialization stuff that is slowing it down
Luke Shannon
@lshannon
Aug 23 2016 21:49
Hi everyone. When I added spring-cloud-services-starter-service-registry to an existing spring boot application I get the following error
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:54)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:104)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:61)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
Caused by: java.lang.IllegalArgumentException: Unable to load [org.springframework.context.ApplicationContextInitializer] factories from location [META-INF/spring.factories]
for sure its a dependancy issue, working to track it down
just wondering if anyone else has seen this?
Spencer Gibb
@spencergibb
Aug 23 2016 22:28
@lshannon I haven't seen that before