Umut Working
Umut Working

Reputation: 51

Spring Boot - Starting 2 Tomcat services on different ports

I need 2 seperate REST APIs in my project, binding and listening to different ports. If enabled, spring initializes a Tomcat with the port given in server.port parameter in application.properties file. I want to start an additional Tomcat service at a different port.

Ideally I would like to bind functions to calls with annotations just like I would with the original Tomcat service (e.g. @RequestMapping @GetMapping etc.)

Is there a way to achieve this without going through the hassle of manually initializing a new Service and binding functions to it?

Upvotes: 0

Views: 391

Answers (1)

Morteza
Morteza

Reputation: 662

I guess you need to have two instances running on different ports and do the same job. Is it true? If yes, you need load balancer.

If you are familiar with eureka and zuul you can achieve your goal by mixing them.

I list the general steps but you need to do a bit of research.

1- create your application. 2- start 2 instances of your application and register them to eureka discovery service 3- create a zuul gateway and distribute the coming requests among running instances.

Upvotes: 1

Related Questions