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

11th
Aug 2016
Johan van den Berg
@johanvdb
Aug 11 2016 10:23
Hi everyone. I am busy developing a microservices gaming system using spring-cloud extensively. I have a few services running and talking to each other via both feign and rabbitmq, with an angularjs frontend talking to the services via zuul proxy. I now would like to create a few "jobs" that run once a day that processes data in the accounting service, and am feeling quite overwhelmed with the multitude of options available in spring. I have read through spring-batch, spring-cloud-task, spring-data-flow and spring-shell documentations, and cannot decide which would be the best tool for the job. The only pre-requisite would be that we can update the task separate from the service that it targets, and that there should only be one instance of a given task run at any time. Your advice will be greatly appreciated.
One of the bigger challenges I foresee is that the Feign clients don't run easily outside of a web application request context, but I am sure there is an easy solution to get past that. Does someone maybe have an example on how to use Feign with Ribbon and Hystrix within a spring-shell type application?
Marcin Grzejszczak
@marcingrzejszczak
Aug 11 2016 11:32
@mminella ^^ do you have a suggestion on the batch tool ?
szisti
@szisti
Aug 11 2016 13:52
hi guys
i'm still struggling with the config server, where I use the .properties or .yaml endpoints, I've created a small sample project, with the description of my issue here: https://github.com/szisti/config-server
when i have an alternative repo with a searchPaths definition, I get response data from lower levels
Michael Minella
@mminella
Aug 11 2016 14:07
@johanvdb What you're looking for sounds like a combination of Spring Cloud Task and Spring Batch (potentially). Spring Cloud Task has capabilities to launch tasks based on messages easily and since those tasks can be boot uber jars sitting in a maven repository somewhere, their ability to be updated is pretty easy. Feel free to ping me directly to discuss your use case in more detail.
Thibaud Lepretre
@kakawait
Aug 11 2016 16:07

@spencergibb about spring-cloud/spring-cloud-netflix#1235 I found those comment really interesting https://github.com/spring-cloud/spring-cloud-netflix/issues/435#issuecomment-191326711 about reusing url property and adding same feature as RestTemplate like http://<serviceId>/.

That should allow user to customize easily the route.
For example for issue spring-cloud/spring-cloud-netflix#435 we can resolve solution by adding such configuration:

zuul:
  routes:
    uaa-service:
      path: /user/**
      url: http://uaa-service/uaa
      strip-prefix: false

or even this one should work

zuul:
  routes:
    uaa-service:
      path: /user/**
      url: http://uaa-service/uaa/user
      strip-prefix: true

Regarding spring-cloud/spring-cloud-netflix#1235 something like

zuul:
  routes:
    user-service:
      path: /api/users/**
      url: http://user-service/users
      strip-prefix: true
    image-service:
      path: /api/images/**
      url: http://image-service/images
      strip-prefix: true
    web-service
      path: /web/login/**
      url: http://web-service/login
      strip-prefix: true

About X-Forwarded-Prefix simply apply such logic:

If strip-prefix: false nothing to do, prefix will be the same.
If strip-prefix: true retrieves previous logic from PreDecorationFilter + prepend with URI.create(url).getPath().

However there is just one point:

How to switch determine if url is normal URL or with register serviceId?

I was thinking about adding new properties on ZuulRoute property: boolean loadBalanced. Thus each previous sample should add:

zuul:
  routes:
    uaa-service:
      path: /user/**
      url: http://uaa-service/uaa
      strip-prefix: false
      load-balanced: true

load-balanced can be default false but if true it will simply switch from SimpleHostRoutingFilter to RibbonRoutingFilter that will activate both load balancing (service discovery) and circuit breaking

Do you think it could be a good solution for fixing both issues?

sorry for long long message :shipit:
Thibaud Lepretre
@kakawait
Aug 11 2016 16:20
but load-balanced could be strange if is set to false with serviceId (without url) because it's no sense. A validation can be done on ZuulProperties to avoid that contradiction
Spencer Gibb
@spencergibb
Aug 11 2016 16:20
that was what I was thinking
Thibaud Lepretre
@kakawait
Aug 11 2016 16:21
but it a bit like adding serviceId and url on same route.
actually I write my own ZuulFilter all above is working (except that I break standard url, because I activate it by default... just a poc). I was thinking about fallback strategy that try to get serviceId if fail fallback to standard request
but it can be dommageable in term of performance
if you are sure that we will not use service-registry at all for some routes