Combination of EventBus and RESTFul API

192 views
Skip to first unread message

Eric Koston

unread,
Oct 4, 2016, 9:27:55 AM10/4/16
to vert.x
Hi all 

I've found a very good tutorial about vertx and microservices. All the example can be downloaded on github. 
I downloaded the sample from github and have found, that some of the microservices are using both EventBus and RESTFul API for they communication interface, for example the product microservice. 

The start method clarify what I mean:

public void start(Future<Void> future) throws Exception {
super.start();

// create the service instance
ProductService productService = new ProductServiceImpl(vertx, config());
// register the service proxy on event bus
ProxyHelper.registerService(ProductService.class, vertx, productService, SERVICE_ADDRESS);
// publish the service in the discovery infrastructure
initProductDatabase(productService)
.compose(databaseOkay -> publishEventBusService(ProductService.SERVICE_NAME, SERVICE_ADDRESS, ProductService.class))
.compose(servicePublished -> deployRestService(productService))
.setHandler(future.completer());
}


As you can see, the service will expose on eventbus and as rest api. Why both? 

Thanks

ad...@cs.miami.edu

unread,
Oct 4, 2016, 3:55:31 PM10/4/16
to vert.x
>some of the microservices are using both EventBus and RESTFul API fo

I think that it all boils down to how a project wants to expose and consume mirco-services.   Vertx provides both EB and Http-REST. One can create a system in which a mciroservice is deployed on both automatically, which may benefit a variety of consumers.  However, I think if this (automatically deploying both) is done too often, it could lead to an API mess. I would stick to one way (EB or REST) of doing it in general, and then expose the service to the other format (EB or REST) using a singe entry service proxy api - that then integrates with the other microservices behind the scenes.  But to each there own! - which is a nice thing about vertx.

-Adam
Reply all
Reply to author
Forward
0 new messages