简体   繁体   中英

How can I call a service API running in an another port via rest template?

There are two services - /getEmployeeSalaryDetails and /CalculateAverageSalary

nginx redirect to 10092,if a user hit the API- /getEmployeeSalaryDetails.

I want to call a /getEmployeeSalaryDetails from /CalculateAverageSalary internally (from port 8080).

I tried to call /getEmployeeSalaryDetails API via restTemplate, I want to know the flow ,Does this restTemplate call go via ngnix ,Since it's http call.

and add on to the doubt,

Should I need to write a grpc (.proto) to call a service /getEmployeeSalaryDetails which is inside an rpm ,running in a server. or restTemplate is enough ?

Note:

/getEmployeeSalaryDetails API is written in GO lang inside an rpm, /CalculateAverageSalary is written in java inside a war.

Q-1:- I tried to call /getEmployeeSalaryDetails API via restTemplate, I want to know the flow ,Does this restTemplate call go via ngnix ,Since it's http call.

It depends on URL(protocol://host:port) in your resttemplate. Say, your getEmployeeSalaryDetails and CalculateAverageSalary service are on same host, and you use http://localhost:8080/getEmployeeSalaryDetails URL in rest-template from CalculateAverageSalary, then it will not go to nginx as localhost:8080 resolves locally.

But, if you use http://somehost.com/getEmployeeSalaryDetails from CalculateAverageSalary, then it will not go to nginx, then call goes to 8080 via proxy if so.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM