Vertx and Eventbus
Vertx uses an Eventbus, which is a neat way of decoupling different components inside a system. Instead of these components calling each other directly they simply send a message on the event bus and whatever system that is interested receives the message. The idea is pretty simple and not really a new one. There is a limitation though. Vertx has been built with cluster support at it’s core.
Cluster support means that Vertx always have to assume that the message you are sending might want to be sent to code running on other machines. This means that you can’t just send any object, it has to be something that is serializable. This in turn might sometimes be an annoyance. If you have many subscribers and you want to write a high performance application you might need reactive nature of
Vertx while at the same time avoiding the overhead of constantly serializing/deserializing objects. Now how can you do this?
runOnContext to the rescue.
runOnContext is a way to schedule a piece of work on a verticle’s thread without going through the complication of any serialization/deserialization using codecs.