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

16th
Aug 2016
mittyok
@mittyok
Aug 16 2016 06:05
Hello, how to use region in spring cloud without AWS?
@joshlong Hello, how to use region in spring cloud without AWS? Is there a demo?
Dave Syer
@dsyer
Aug 16 2016 06:44
What do you mean by "region" when it's not AWS? What would you expect to be able to do?
mittyok
@mittyok
Aug 16 2016 07:00
Hi @dsyer , thank you, can I let eureka client discover only part of service providers from eureka server!
Dave Syer
@dsyer
Aug 16 2016 07:02
No, it doesn't work like that. You can control the way that eureka shares its registry amongst instances of the server. And you can control the load balancing in the client (ribbon).
But the client always gets a full catalog from the server.
mittyok
@mittyok
Aug 16 2016 07:04
there is a concept of 'region' when eureka is used in AWS!
it can do what I said...
in spring cloud, the concept does not work , right ? @dsyer
Dave Syer
@dsyer
Aug 16 2016 07:13
Where is it used?
I'm not sure I follow
EurekaClientConfig has a region property. I don't think any of the AWS behaviour is obscured by Spring Cloud.
Dave Syer
@dsyer
Aug 16 2016 07:19
It is used to select a server instance I think.
But you can't filter the data the client is getting from a single server instance.
mittyok
@mittyok
Aug 16 2016 07:32
@dsyer OK, if that, how to set server region?
Dave Syer
@dsyer
Aug 16 2016 07:34
Set it where?
mittyok
@mittyok
Aug 16 2016 07:35
I specify the region use eureka.client.region at server, but it does not work, at client I can always found service providers with any region....
Dave Syer
@dsyer
Aug 16 2016 07:36
Yes, that's why I said, the client always pulls the whole catalog from the server. There's no filter.
If you have multiple servers you can select one using the client region.
region->az->serviceUrl
(there are 2 maps in EurekaClientConfigBean I think, that make that chain, but the contract is defined by the eureka core API)
mittyok
@mittyok
Aug 16 2016 07:39
blob
blob
blob
It said, (used in AWS datacenters) where this instance resides
@dsyer Thank you! Now could you give me a example, how to config region at client and server, and how it works?
I haven't found some docs for that!
ccit-spence
@ccit-spence
Aug 16 2016 07:45
@mittyok You may want to take a look at the Netflix docs, https://github.com/Netflix/eureka/wiki/Eureka-at-a-glance
I have not tried working with regions
Per this it seems to be how you want it to work Deploying Eureka in multiple AWS regions is a fairly straightforward task. Eureka clusters between regions do not communicate with one another.
mittyok
@mittyok
Aug 16 2016 07:50
@ccit-spence yea, this doc just said for aws
I just want to know, how it works for only spring cloud and what it affects
ccit-spence
@ccit-spence
Aug 16 2016 07:51
To my knowledge aws is the only place it will work, it is specific behavior created by Netflix for their use of AWS
@dsyer is that a correct statement
mittyok
@mittyok
Aug 16 2016 07:53
OK, Looks that, @dsyer had another opinion! @ccit-spence thank you very much....
Dave Syer
@dsyer
Aug 16 2016 07:55
It sounds like the same thing I said
Spring Cloud doesn't do anything to obscure those features
mittyok
@mittyok
Aug 16 2016 07:58
OK! Thank you! @dsyer @ccit-spence
ccit-spence
@ccit-spence
Aug 16 2016 08:11
@dsyer Do you know much about how Sleuth and Zipkin work?
@mittyok You could use properties specifc to a “region” to mimic the same behavior.
Marcin Grzejszczak
@marcingrzejszczak
Aug 16 2016 08:13
@ccit-spence how can I help you with Sleuth and Zipkin?
btw there is a separate channel for Sleuth - https://gitter.im/spring-cloud/spring-cloud-sleuth but we can continue here if you want to
ccit-spence
@ccit-spence
Aug 16 2016 08:14
I will jump over
Jose Armesto
@fiunchinho
Aug 16 2016 13:26
sending a PUT request to an API through Zuul returns 400 Bad Requestkind of randomly. If I send the same request directly to the API, it always works, but if the request goes through Zuul, it sometimes returns 200 OK, sometimes fails
analyzing packages with tcpdump shows an strange behaviour of one http request receiving two http responses, which it shouldn't happen at all
the API behind zuul is an Spring Boot application returning a Single object, and it sends chunks responses to Zuul
anyone has any idea what could be going on?
Dave Syer
@dsyer
Aug 16 2016 13:28
Chunks are probably the issue. Zuul is not designed for streaming at all.
If you have a sample app that would help to disgnose
Jose Armesto
@fiunchinho
Aug 16 2016 13:33
we have the project under a private repository, but reproduce the problem using Zuul server from spring starter, and one endpoint with just this code in the API
Observable<String> sobs = Observable.create(new Observable.OnSubscribe<String>() {
      @Override
      public void call(Subscriber<? super String> subscriber) {
        try {
          BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));

          String line;
          while((line= br.readLine())!=null) {
            subscriber.onNext(line);
          }
        } catch (Exception e) {
          subscriber.onError(e.getCause());
        } finally {
          subscriber.onCompleted();
        }
      }
    });

    return sobs.first().toSingle();
inputStream is reading a json file from the server to simulate the response
with this code, we get a 400 Bad Request one on every 10-15 requests
it looks like if the inputStream reads a small file, no error is shown, but if the file goes above some bytes, it starts happening
Jose Armesto
@fiunchinho
Aug 16 2016 13:43
so the only solution would be to stop using Single and Observable?
Dave Syer
@dsyer
Aug 16 2016 14:06
Are you using Spring MVC?
Florian Wiesner
@FWiesner
Aug 16 2016 14:40
sounds like an HTTP proxy problem to me
Jose Armesto
@fiunchinho
Aug 16 2016 17:30
the backend API is an Spring Cloud application that gets registered in Eureka
what do you mean @FWiesner ?
Dave Syer
@dsyer
Aug 16 2016 17:33
How is the Observable turned into an output stream for the http request?
Jose Armesto
@fiunchinho
Aug 16 2016 17:37
not sure about what you mean, the code I pasted above is from a @restcontroller, inside a method annotated with @requestmapping
Dave Syer
@dsyer
Aug 16 2016 18:50
So you could have answered "yes" when I asked if it was spring MVC.
Spring MVC doesn't support Observable return types in a @RequestMapping though (not in 4.x anyway).
Spencer Gibb
@spencergibb
Aug 16 2016 18:52
@dsyer we do have some support in s-c-netflix
Dave Syer
@dsyer
Aug 16 2016 18:52
So you are using the spring cloud handler. It's not mainstream.
Spencer Gibb
@spencergibb
Aug 16 2016 18:52
yeah, it will definitly go away with boot 2 and spring 5
Dave Syer
@dsyer
Aug 16 2016 18:53
And I don't think I know how it works well enough to predict how Zuul will behave in front of it
Marcos Barbero
@marcosbarbero
Aug 16 2016 19:07

I’m working with spring-cloud-stream with rabbit binder and facing the following exception when I shutdown my service

2016-08-16 16:00:41.985  WARN 85502 --- [z6b5lsSTC4SxA-6] o.s.a.r.l.SimpleMessageListenerContainer : Consumer raised exception, processing can restart if the connection factory supports it

java.lang.IllegalStateException: The ApplicationContext is closed and the ConnectionFactory can no longer create connections.
    at org.springframework.util.Assert.state(Assert.java:392) ~[spring-core-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:520) ~[spring-rabbit-1.5.6.RELEASE.jar:na]
    at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils$1.createConnection(ConnectionFactoryUtils.java:85) ~[spring-rabbit-1.5.6.RELEASE.jar:na]
    at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.doGetTransactionalResourceHolder(ConnectionFactoryUtils.java:135) ~[spring-rabbit-1.5.6.RELEASE.jar:na]
    at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.getTransactionalResourceHolder(ConnectionFactoryUtils.java:71) ~[spring-rabbit-1.5.6.RELEASE.jar:na]
    at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:456) ~[spring-rabbit-1.5.6.RELEASE.jar:na]
    at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1171) ~[spring-rabbit-1.5.6.RELEASE.jar:na]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_66]

2016-08-16 16:00:41.986  INFO 85502 --- [z6b5lsSTC4SxA-6] o.s.a.r.l.SimpleMessageListenerContainer : Restarting Consumer: tags=[{}], channel=null, acknowledgeMode=AUTO local queue size=0

anyone has faced same issue? what to do in that case?

Dave Syer
@dsyer
Aug 16 2016 19:11
It's just a warning. Probably ignore it.
@fiunchinho the most likely explanation for intermittent failures in a ribbon client (i.e. zuul) is a timeout. Hard to say without more data. A sample for instance.