June 2018
Beginner
722 pages
18h 47m
English
The message consumer in Vert.x is a verticle that registers with the event bus as a potential receiver of the messages sent or published to the specified address:
package com.packt.javapath.ch18demo.reactivesystem;import io.vertx.rxjava.core.AbstractVerticle;public class MsgConsumer extends AbstractVerticle { private String address, name; public MsgConsumer(String id, String address) { this.address = address; this.name = this.getClass().getSimpleName() + "(" + id + "," + address + ")"; } public void start() throws Exception { System.out.println(name + " starts..."); vertx.eventBus().consumer(address).toObservable() .subscribe(msg -> { String reply = name + " got message: " + msg.body(); System.out.println(reply); if ("undeploy".equals(msg.body())) ...
Read now
Unlock full access