chapter two

2 Verticles: the basic processing units of Vert.x

 

This chapter covers:

  • What verticles are
  • How to write, configure, and deploy verticles
  • The Vert.x threading model
  • How to mix Vert.x and non-Vert.x threads

Put simply, a verticle is the fundamental processing unit in Vert.x. The role of a verticle is to encapsulate a technical functional unit for processing events, such as exposing an HTTP API and responding to requests, providing a repository interface on top of a database, or issuing requests to a third-party system. Much like components in other technologies like Enterprise Java Beans, verticles can be deployed, and they have a life cycle.

Asynchronous programming is key to building reactive applications, since they have to scale, and verticles are fundamental in Vert.x for structuring (asynchronous) event processing code and business logic.

2.1  Writing a verticle

2.1.1  Preparing the project

2.1.2  The verticle class

2.1.3  Running and first observations

2.2  More on verticles

2.2.1  Blocking and the event loop

2.2.2  Asynchronous notification of life-cycle events

2.2.3  Deploying verticles

2.2.4  Passing configuration data

2.3  When code needs to block

2.3.1  Worker verticles

2.3.2  The executeBlocking operation

2.4  So what is really in a verticle?

2.4.1  Verticles and their environment

2.4.2  More on contexts

2.4.3  Bridging Vert.x and non-Vert.x threading models

2.5  Summary