0

I want to run multiple, non-clustered verticles on my webserver. Each verticle is started by a separate process/commandline and creates his own HTTP server (vertx.createHttpServer) for the same host and the same port with unique routes. However, this does not seem to work because after starting one verticle, all further verticles throw a BindException "Address already in use".

As a Vert.x novice I can only think of two ways to get passed this:

  1. Programmatically deploy all verticles from a single process, and make all verticles use a global router instance for adding their specific routes.
  2. Cluster the verticles and create an additional verticle that provides a webserver which allows to setup routes and handle requests and response via the clustered eventbus.

Both approaches would force me to rewrite large parts of my verticles.

Is there another way to circumvent this multiserver issue?

4

1 回答 1

1

每个 Verticle 由一个单独的进程/命令行启动,并为同一主机和同一端口创建自己的 HTTP 服务器(vertx.createHttpServer)

TCP 连接只允许单个进程在同一主机上的同一端口上侦听。有一些方法可以解决这个问题(请参阅对此问题的回复),但我不确定这样做是否是最好的解决方案。

...对于具有唯一路由的同一主机和同一端口

Vertx-Web提供了许多路由请求的方法。我最近使用的一种方法是sub-router,这对您来说可能是一个可行的解决方案。您可以配置一个“主”路由器,为您想要的每个“唯一路由”将请求路由到不同的路由器。

于 2018-08-29T03:47:12.430 回答