4

Vert.x virtual host server for other vert.x apps

As illustrated above, I need to build a Vert.x Java app that will be an HTTP server/virtual host (TLS Http traffic, Web socket traffic) that will redirect/channel specific domain traffic to other Vert.x Java apps running on the same server, each in it's own JVM.

I have been reading for days but I remain uncertain as to how to approach all aspects of the task.

What I DO know or have experience with:

  • Creating an HTTP server, etc
  • Using a Vert.x VirtualHost handler to "handle" incoming traffic for a specific domain

What I DO NOT know:

  • How do I "re-direct" a domain's traffic to another Vert.x app (this other Vert.x app would also be running on the same server, in its own JVM).

    - Naturally this "other" Vert.x app would need to respond to HTTP requests, etc. What Vert.x mechanisms do I employ to accomplish this aspect of the task?

Are any of the following concepts part of the solution? I'm unfamiliar with these concepts and how they may or may not form part of the solution.:

  • Running each Vert.x app using -cluster option?

  • Vert.x Streams?

  • Vert.x Pumps?

Dale K
  • 25,246
  • 15
  • 42
  • 71
rs99483
  • 75
  • 4

1 Answers1

1

There are multiple ways to let your microservices communicate with each other, the fact that all your apps are running on the same server doesn't change much, but it makes number 2.) easy to configure

1.) Rest based client - server communication

  • Both host and apps have a webserver
  • When you handle the incoming requests on the host, you simply call another app with a HttpClient

enter image description here

Typically all services find each others address via service discovery. Eg: each service registers his address in a central registry then other services use this central registry to find the addresses.

Note: this maybe an overkill for you and you can just configure the addresses of the other services.

2.) You start the vertx microservices in clustered mode

  • the eventbus is then shared among the services
  • For all incoming requests you send a broadcast on the eventbus
  • the responsible app replies to the message

enter image description here

For further reading you can checkout https://vertx.io/docs/vertx-hazelcast/java/#configcluster. You start your projects with -cluster option and define the clustering in an xml configuration. I think by default it finds the services via local broadcast.

3.) You use a message broker like RabbitMq etc.

  • All your apps connect to a central message broker
  • When a new request comes in to the host, it sends a message to the message broker
  • The responible app then listens to the relevant messages and replies
  • The host receives the reply from the message broker

enter image description here

There are already many existing vertx clients for certain message brokers like kafka, camel, zeromq:

https://github.com/vert-x3/vertx-awesome#integration

taygetos
  • 3,005
  • 2
  • 21
  • 29