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

25th
Jan 2018
Haruhiko Nishi
@hanishi
Jan 25 2018 13:21
Does anyone know how if a String[] type property of a @ConfigurationProperties annotated class can have string values with commas? For instance, "0,1,2" or "192.168.1.1, 192.168.1.2"?
If a value with commas can be set as a single array element for the https://github.com/spring-cloud-task-app-starters/spark-cluster'sspark.app-argsproperty which is a String[] type, I can pass multiple values to a command line option that expect --brokers <ip1>,<ip2> or --partitions 0,1,2
Dave Syer
@dsyer
Jan 25 2018 13:44
Not really a spring-cloud question. Did you check the Spring Boot user guide?
Did you try it and it didn't work?
Haruhiko Nishi
@hanishi
Jan 25 2018 13:55
Right, I just found spring-boot ROOM, I will bring this topic to there. I tried different possible ways, but nothing worked. if value itself has commas it get separated by commas and each one of them become the elements of the String[] property.
Guilherme Blanco
@guilhermeblanco
Jan 25 2018 17:13
Hi! I need to inject a built concrete class created by OpenFeign into a Configuration that takes a higher precedence (due to WebSocket interceptors). How can I achieve that? Here’s my sample code: https://gist.github.com/guilhermeblanco/60a819b45318454bf088aa2566debd59#file-relayauthenticationconfiguration-java-L37
Dave Syer
@dsyer
Jan 25 2018 17:14
"higher precedence" doesn't really make sense in that sentence
Higher precedence for what?
Guilherme Blanco
@guilhermeblanco
Jan 25 2018 17:15
Sorry, had to switch to browser Gitter as my gist took over my whole Electron app.
I set the @Order to allow me to inject a WS Channel Interceptor
Dave Syer
@dsyer
Jan 25 2018 17:16
I don't think that makes any difference.
Guilherme Blanco
@guilhermeblanco
Jan 25 2018 17:16
Otherwise my authentication interceptor will always perform after Spring Security's one
Dave Syer
@dsyer
Jan 25 2018 17:16
But I don't know what a "WS Channel Interceptor" is , so I'm probably missing something
Whatever all that is, it has nothing to do with Feign, or dependency injection.
So I don't know what the problem is yet
Guilherme Blanco
@guilhermeblanco
Jan 25 2018 17:18
WebSocket handling is done through a list of interceptors, named channel interceptors. Each Spring component registers itself at different precedence order to perform the desired operation. One of the examples is Spring Security, which registers at highest precedence + 100 to perform authorization of WS messages
Dave Syer
@dsyer
Jan 25 2018 17:19
But that's an ordering at runtime, when a WS connection request is being handled.
Isn't it?
Guilherme Blanco
@guilhermeblanco
Jan 25 2018 17:19
yes
Dave Syer
@dsyer
Jan 25 2018 17:19
Seems unrelated to Feign or DI
Feign classes are synthesised and DI is done when the context is refreshing (long before any WS requests are handled)
Guilherme Blanco
@guilhermeblanco
Jan 25 2018 17:20
My challenge is that due to restrictions on interceptor registration, I somehow need to access Beans (and implement the Bean instantiation method) that are used by that class
that means I somehow need to know how to access the built Feign class (or at least know its class name)
Dave Syer
@dsyer
Jan 25 2018 17:21
If you can distil the problem down to a handful of beans in a Spring Boot app, I might understand.
Feign clients cal be injected by type
There's no need to know the concrete type
Guilherme Blanco
@guilhermeblanco
Jan 25 2018 17:22
Sorry @dsyer, I can compile an app that illustrates the issue, but the problem happens at my gist published class (line 37)
Dave Syer
@dsyer
Jan 25 2018 17:23
Why can't you @Autowired it?
Guilherme Blanco
@guilhermeblanco
Jan 25 2018 17:24
method configureClientInboundChannel is an override of abstract method in AbstractWebSocketMessageBrokerConfigurer and I don’t know how to access Beans from there besides creating them as part of the same class and calling the respective methods.
@Autowire does not work because it breaks API compliance with AbstractWebSocketMessageBrokerConfigurer method
Dave Syer
@dsyer
Jan 25 2018 17:24
I don't understand. You already @Autowired a RelayAuthenticationProperties
Guilherme Blanco
@guilhermeblanco
Jan 25 2018 17:25
OMG
yes
guilhermeblanco @guilhermeblanco hides in shame
Guilherme Blanco
@guilhermeblanco
Jan 25 2018 17:26
I probably spent too much time trying to fix it and became blind
Dave Syer
@dsyer
Jan 25 2018 17:26
It happens
Guilherme Blanco
@guilhermeblanco
Jan 25 2018 17:29
@dsyer and thanks a lot for putting a lot of effort in such great tools. =) I work with lots of OSS in PHP and understand how tiring maintaining highly used packages are. Seriously, thank you.
Dave Syer
@dsyer
Jan 25 2018 17:31
No sweat.
Tyler Thrailkill
@snowe2010
Jan 25 2018 17:36
@dsyer switching from brixton to camden.sr7 caused x-forwarded-host to append the port to the url. Is there any way to get the old functionality back? where there was a separate x-forwarded-port?
ah sorry, in spring-cloud-starter-parent/spring-cloud-starter-zuul
Dave Syer
@dsyer
Jan 25 2018 17:40
We're not really supporting Camden any more, but I don't know.
Tyler Thrailkill
@snowe2010
Jan 25 2018 17:47
@dsyer what is the latest version then?
Dave Syer
@dsyer
Jan 25 2018 17:48
Edgware.SR1
Tyler Thrailkill
@snowe2010
Jan 25 2018 18:07
dang, using Edgware.SR1 causes this error on start.

[INFO] --- spring-boot-maven-plugin:1.5.6.RELEASE:run (default-cli) @ gateway ---
11:01:35.018 [main] DEBUG io.fabric8.kubernetes.client.Config - Trying to configure client from Kubernetes config...
11:01:35.024 [main] DEBUG io.fabric8.kubernetes.client.Config - Found for Kubernetes config at: [/Users/tylerthrailkill/.kube/config].
[WARNING]
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:498)
        at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:527)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Cannot find class [org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration]
        at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:287)
        at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:176)
        at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:102)
        at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:68)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:121)
        at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:68)
        at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
        at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:335)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
        at com.promontech.lp.gateway.GatewayApplication.main(GatewayApplication.java:18)
        ... 6 more
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at org.springframework.util.ClassUtils.forName(ClassUtils.java:250)
        at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:284)
        ... 17 more
Tyler Thrailkill
@snowe2010
Jan 25 2018 18:19
I had a spring-boot-starter-parent version mismatch. Who could I talk to about the x-forwarded-host header?
Dave Syer
@dsyer
Jan 25 2018 18:46
There is probably an open issue in github
@ryanjbaxter usually ends up with this stuff on his plate
But I expect you’ll have to upgrade whatever happens
Guilherme Blanco
@guilhermeblanco
Jan 25 2018 18:59
@dsyer I can’t @Autowire the FeinClient class into that Configuration class. It generates a circular dependency. Any other suggestions?
Dave Syer
@dsyer
Jan 25 2018 19:01
Not without some code to run
Guilherme Blanco
@guilhermeblanco
Jan 25 2018 19:01
will do it
that will likely require a message broker (RabbitMQ) due to broker security configuration (the need for the precedence)
Tyler Thrailkill
@snowe2010
Jan 25 2018 20:47
here is the issue in github. It seems like x-forwarded-port was not a proper header in the first place, so I expect it won't be back.
spring-cloud/spring-cloud-netflix#1895
thanks for the help though!
Dave Syer
@dsyer
Jan 25 2018 22:03
I think the jury may still be out on that.
Do you have an example of a backend app that works with x-forwarded-port in a form that isn't currently supported?
dennyh89
@dennyh89
Jan 25 2018 22:12
HI all. i am trying to find samples about how to use spring-cloud-stream with mqtt. it seemed it is somehow possible looking at https://github.com/spring-cloud-stream-app-starters/mqtt
but i am quite unsure on how it works, because starting a @EnableBinding annotated application with just the starter in dependencies complains about missing binders. which in fact is only present for kafka and rabbit!?
Dave Syer
@dsyer
Jan 25 2018 22:13
There's no MQTT binder as far as I know (but other people have asked about it, so someone might have implememted one, for all I know)
dennyh89
@dennyh89
Jan 25 2018 22:14
and what is the stream-app-starter mqtt for?
Dave Syer
@dsyer
Jan 25 2018 22:14
The app starters are source and sink apps to and from MQTT into and out of Spring Cloud Stream.
dennyh89
@dennyh89
Jan 25 2018 22:14
maybe i miss the oncept of those projects!?
Dave Syer
@dsyer
Jan 25 2018 22:14
It seems you did
There are a huge number of app starters there.
MQTT happens to be one that covers a message broker
If you look at it in comparison with the rest it might make more sense
dennyh89
@dennyh89
Jan 25 2018 22:15
is this described somewhere? looks i do not understand the source/sink concept related to stream
dennyh89
@dennyh89
Jan 25 2018 22:16
other types are email, http and stuff. so i thought its just converting source (mqtt) into stream interface conform messages
Dave Syer
@dsyer
Jan 25 2018 22:16
Yes. That sums it up.
dennyh89
@dennyh89
Jan 25 2018 22:17
so shouldnt it be possible to consume mqtt messages with stream? i dont get the difference to binders probably :D
Dave Syer
@dsyer
Jan 25 2018 22:18
With the MQTT source app, you consume an MQTT message and relay it into SCS (kafka, rabbit, etc.)
Replace MQTT with "X" in that last sentence, where X is any of the supported sources
dennyh89
@dennyh89
Jan 25 2018 22:19
which means i have this source app to get mqtt messages and protocol translate them to AMQP (rabbit) ?
Dave Syer
@dsyer
Jan 25 2018 22:20
"protocol" is probably a loose description
But Rabbit is one of the supported binders
dennyh89
@dennyh89
Jan 25 2018 22:25
my use case is more of the following app -> mqtt -> spring boot application -> logic & REST call & DB write. i thought stream could automatically bind to mqtt broker. if stream can't i may use rabbit mqtt plugin and consume its messages with normal rabbit binding!?
Dave Syer
@dsyer
Jan 25 2018 22:42
I don’t know what rabbit buys you there. Does it turn Rabbit into an MQTT broker? Why not just use AMQP?
dennyh89
@dennyh89
Jan 25 2018 22:43
hoping for less bandwitdh usage and phone battery consumption
rabbit seems to have aplugin that serves as mqqt broker and translates to AMQP messages in the back
from what i read i have not found any explanation about how source/sink apps add value to stream and how stream is borrowing from spring integration. its a but confusing to me
dennyh89
@dennyh89
Jan 25 2018 22:54
do i need to think of "Binder" as the pre-implemented source and sink adapter for rabbit and kafka, whereas for mqtt,email, ... i need to implement the source and sink methods on my own in my specific application code? so is this pre-implemented code of "BInder" the only benefit ofthe stream project or do i miss anything here?
both "Binder" and Source/Sink use Message Interface from spring integration!?