Skip to content

Instantly share code, notes, and snippets.

@teivah
Created May 30, 2018 13:40
Show Gist options
  • Save teivah/1a3828a0f0641b566d5d8b1f02df36b0 to your computer and use it in GitHub Desktop.
Save teivah/1a3828a0f0641b566d5d8b1f02df36b0 to your computer and use it in GitHub Desktop.
public void start(Future<Void> startFuture) {
//Retrieve the EventBus object form the vertx one
EventBus eventBus = vertx.eventBus();
//Create a EventBus consumer and instantiate a JsonObject type message consumer
MessageConsumer<JsonObject> createConsumer = eventBus.consumer("customer.create");
//Handle new messages on customer.create endpoint
createConsumer.handler(json -> {
System.out.println("Received new customer: " + json.body());
//Enrich the customer object
JsonObject enrichedCustomer = enrichCustomer(json.body());
//Publish (one-to-many) the enriched message on another endpoint
eventBus.publish("customer.completion", enrichedCustomer);
});
startFuture.complete();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment