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

8th
Jun 2018
KaijuDeluxe
@KaijuDeluxe
Jun 08 2018 07:33
Hi, i have a zuul service running and a DB Service, so what should i add to the DBService, that it get a dynamic port from zuul? The DBService will launch with 8080 but its is not available. so i thought zuul will manage the porting? but it won’t?
Marcos Barbero
@marcosbarbero
Jun 08 2018 07:34
let's take a step back, so I can understand what you are trying to do
Are you deploying those services in the same host?
KaijuDeluxe
@KaijuDeluxe
Jun 08 2018 07:36
yes
Marcos Barbero
@marcosbarbero
Jun 08 2018 07:36
now I got it
KaijuDeluxe
@KaijuDeluxe
Jun 08 2018 07:37

so zuul has following properties, may here is a mistake?

zuul.routes.frontend-service.url=http://localhost:8190
zuul.routes.database-service.url=

server.port=8181
spring.application.name=api-gateway-service
eureka.instance.preferIpAddress=true
eureka.client.registerWithEureka=true
eureka.client.fetchRegistry=true

hm now i deleted the line

zuul.routes.database-service.url=

and the dbservice startet. what is that line for?

but now i can t start my frontend service, because the db service uses 8080
how can i manage this correctly?
Marcos Barbero
@marcosbarbero
Jun 08 2018 07:42
that's the thing, I think you misunderstood somethings
KaijuDeluxe
@KaijuDeluxe
Jun 08 2018 07:42
yes :( please teach me
so i am running zuul, db service and a frontendservice (its in payara so 8080 is for the view)
Marcos Barbero
@marcosbarbero
Jun 08 2018 07:43
your problem is just the server.port, there's no such thing as dynamic server port. So if you have it set to 8080, 8081, or whatever, then it will be the port used by the server
KaijuDeluxe
@KaijuDeluxe
Jun 08 2018 07:43
the db service should get its own port by zuul
Marcos Barbero
@marcosbarbero
Jun 08 2018 07:44
what you can get from zuul is a dynamic routing, not a dynamic port
KaijuDeluxe
@KaijuDeluxe
Jun 08 2018 07:44
for every service i need to insert a port??
Marcos Barbero
@marcosbarbero
Jun 08 2018 07:44
you can either deploy them in different hosts/containers or change its port
KaijuDeluxe
@KaijuDeluxe
Jun 08 2018 07:45
so when i am creating a new service i need to add a specific port to the properties?
thats kind of stupid
Marcos Barbero
@marcosbarbero
Jun 08 2018 07:45
if you are running them locally then, yes, you need to set different ports
well, not really stupid I would say
KaijuDeluxe
@KaijuDeluxe
Jun 08 2018 07:46
the same wont happen when i deploy them on my test vserver?
Marcos Barbero
@marcosbarbero
Jun 08 2018 07:47
whenever you deploy everything in the same host it will be a problem
KaijuDeluxe
@KaijuDeluxe
Jun 08 2018 07:48

hm ok how do i configure it if i have 2 server, one with zuul and the db service and the view is on another server. when i make a rest call i added

final String baseURL = "http://localhost:8080/users/getUser/" + loginName;
User result = restTemplate.getForObject(baseURL, User.class);

so then localhost is wrong, do i need to add the specific IP ? What if the IP change?

Marcos Barbero
@marcosbarbero
Jun 08 2018 07:54
are you using any Service Discovery/Registry?
like Eureka, Consul?
if we are talking about microservices, and I do believe we are, you should use a service discovery such as Netflix Eureka, HashiCorp Consul
KaijuDeluxe
@KaijuDeluxe
Jun 08 2018 08:04
yes eureka
Marcos Barbero
@marcosbarbero
Jun 08 2018 08:24
so, you don't really need to configure the zuul.routes url for each service
you can use dynamic routing
KaijuDeluxe
@KaijuDeluxe
Jun 08 2018 08:25
ah ok thats good have i to configure something in zuul?
Marcos Barbero
@marcosbarbero
Jun 08 2018 08:26
@bsushant-athena I was looking into your configuration and it doesn't seem to be correct.
You have EIP and also ipAddress configured, I do believe it's just a matter of misconfiguration
KaijuDeluxe
@KaijuDeluxe
Jun 08 2018 08:28
ah ok i dont configured a mapping in zuul, so no i can access my database service by using http://localhost:8181/database-service/users/getUser/adminNico
Marcos Barbero
@marcosbarbero
Jun 08 2018 08:28
beautiful, right?
:smile:
KaijuDeluxe
@KaijuDeluxe
Jun 08 2018 08:29
very beautiful :smile:
how can i configure it to use it withour database-service name in the url or is this not recommended
Marcos Barbero
@marcosbarbero
Jun 08 2018 08:29
KaijuDeluxe
@KaijuDeluxe
Jun 08 2018 08:39
it wont work :(
zuul.routes.database-service.path=/database-service/**
but i need to call wirh service name in url
Marcos Barbero
@marcosbarbero
Jun 08 2018 08:40
that's basically how the routing is done, it routes based on the serviceId registered on Eureka
you can rename the routing path if needed
KaijuDeluxe
@KaijuDeluxe
Jun 08 2018 08:41
what do you mean with rename?
vikrantch-hk
@vikrantch-hk
Jun 08 2018 08:41
@KaijuDeluxe try with strip-prefix: false
Marcos Barbero
@marcosbarbero
Jun 08 2018 08:42
I mean, instead of routing to /database-service/ you can choose something more suitable like /my-whatever-service/**
KaijuDeluxe
@KaijuDeluxe
Jun 08 2018 08:42
ahh oj
ok
Marcos Barbero
@marcosbarbero
Jun 08 2018 08:43
I don't believe strip-prefix will make any diff @vikrantch-hk
KaijuDeluxe
@KaijuDeluxe
Jun 08 2018 08:43
now i got it
i putted zuul.routes.database-service.path=/**
so i dont need to add database serrvie
in the url
but is this recommended?
Marcos Barbero
@marcosbarbero
Jun 08 2018 08:44
I don't think it is recommended
KaijuDeluxe
@KaijuDeluxe
Jun 08 2018 08:44
ok then i will add a name behind it
thank you very much
Marcos Barbero
@marcosbarbero
Jun 08 2018 08:45
you're welcome
CH4:D
@chad_d_stud_twitter
Jun 08 2018 10:10
how to switch profiles in consul?
Marcos Barbero
@marcosbarbero
Jun 08 2018 10:24
what do you mean?
Onno Schmidt
@ezonno
Jun 08 2018 12:08
I have a question about spring-cloud function and a streaming application.
I see that I can bind to kafka via cloud-stream. Will this work on AWS also? Is it the idea that the function starts consuming once it's triggered?
If so, when will the function halt?
Mario Romano
@magemello
Jun 08 2018 12:21
Hi...does anyone know how to set the local address of the spring WebClient ?
pradeepkusingh
@pradeepkusingh
Jun 08 2018 15:42
How can I use zuul fallback provider to send the request to another server or fall back url?
pradeepkusingh
@pradeepkusingh
Jun 08 2018 17:09
How can I use below proeprty in my zuul
clientName:
ribbon:
retryableStatusCodes: 404,502
would it conflict with zuul retry property?
@ryanjbaxter
Fabricio
@ofabricio
Jun 08 2018 22:44
Something we use a lot here with zuul is to enable/disable a route with redis. Is that also possible with spring-gateway?