This chapter covers:
- What is the event-bus,
- How to have point-to-point, request-reply and publish / subscribe communications over the event-bus,
- The distributed event-bus for verticle-to-verticle communications across the network.
The previous chapter introduced verticles. A Vert.x application is made of 1 or more verticles, and each verticle forms a unit for processing asynchronous events. It is common to specialize verticles by functional and technical concerns, such as a verticle for exposing a HTTP API and a verticle for dealing with a data store. This design also encourages deploying several instances of a given verticle for scalability purposes.
Now what we did not cover is how verticles can communicate with each other. Back to the previous example a HTTP API verticle needs to talk to the data store verticle if the larger Vert.x application is doing anything useful.
Connecting verticles and making sure they can cooperate is exactly the role of the event-bus.
The event-bus is a mean for sending and receiving messages in an asynchronous fashion. Messages are being sent (and retrieved) from destinations. A destination is simply a free-form string, such as incoming.purchase.orders
or incoming-purchase-orders
, although the former form with dots is preferred.