Java Magazine, Jan/Feb 2018
ORACLE COM JAVAMAGAZINE JANUARY FEBRUARY 2018 47 reactive programming vertx createHttpServer 3 Attach a request handler processing the requests requestHandler req req response end Hello request handled from Thread currentThread getName 4 Start the server on the port 8080 listen 8080 For each incoming HTTP request event the request handler is called Notice that the handler is always called by the same thread the event loop thread Now if you want to call another service using HTTP in the request handler you would do something like this package samples import io vertx core Vertx import io vertx ext web client WebClient public class TwitterFeedApplication public static void main String args Vertx vertx Vertx vertx 1 Create a Web client WebClient client WebClient create vertx vertx createHttpServer requestHandler req 2 In the request handler retrieve a Twitter feed client getAbs https twitter com vertx_ project send res
You must have JavaScript enabled to view digital editions.