On Java framework Vert. Some thoughts on x
Introduction of Vert. X
In Java20 anniversary, Java users complained about Java, such as memory management, heavy JavaEE, etc.And Java remains in the list of TIOBE programming language difficult to maintain the first position, with the development of some new programming language, this area presents a rough-and-tumble state at present.
In this context, the Java small fresh framework -- Vert. On May 7, 2015 x 3.0 milestone5 version released, distance plan released on June 22nd Vert. X3.0.0 - more and more closer to the final, Vert. X user group of fans in the near future can't wait in the center of the universe (note: Beijing wudaokou) organized a Vert. X user Meetup group in China, aiming at Vert. X engineering development problems and Vert. X3 launched to explore the new features.Vert. X (http://vertx.io/) is an application platform based on the JVM, lightweight, high-performance, very suitable for the mobile terminal of the latest background, the Internet, the enterprise application architecture.
Netty Vert. X-ray based on asynchronous Java server, and extend out of the many useful features.Vert. X window are:
Asynchronous unlocked programming - classic multithreaded programming model can satisfy the many Web development scenarios, but with the mobile Internet a surge in the number of simultaneous connections, multi-threaded concurrent control model performance is difficult to extend, at the same time to control the concurrent lock need to higher skills, the Reactor started their asynchronous programming model, and Vert. X is the asynchronous programming unlocked a preferred;
Rich support for various IO -- the Vert. X asynchronous model has support for TCP, UDP, FileSystem, DNS, EventBus, Sockjs, etc;
Excellent distributed development support - Vert. X through EventBus event bus, you can easily write distributed decoupling applications, has a good scalability;
Ecological system maturing -- Vert. X into the Eclipse foundation under, asynchronous driver has supported the Postgres, MySQL, common components, such as directing, Redis and several Vert. X application case in a production environment.
Compared with the traditional framework of Java multi-thread model, Vert. X Netty is a Java implementation model of Reactor.Archaeology of the Reactor model, the theory of the earliest by Washington University of Douglas c. Schmidt, the professor put forward in 1995, in "Proactor - An Object Behavioral Pattern for Demultiplexing and Dispatching Handlers for Asynchronous Events, this paper made a complete introduction.
Figure 1-6 is analyzing the principle of its key parts.
Figure 1 a classic Web Server after receiving Web browser request processing
Figure 2 a classic Web Server using multithreading model, concurrent processing a request from the browser of multiple Web clear
Figure 3 a Web browser is connected to a Reactor model of the Web Server process.Use the Initiation Dispatcher component, the time-consuming IO operations event registration to Initiation Dispatcher component
Figure 4 Web browser to access a Reactor model of the Web Server process.Time consuming IO operations performed by the other thread, IO after the completion of the execution notice Initiation Dispatcher, back to the Http Handler
Figure 5 Web browser to connect a Proactor pattern of the Web Server process.And Reactor time-consuming IO operations to the operating system is the main difference between asynchronous I/o library (such as GNU/Linux aio), operating system, asynchronous I/o library after the execution by asynchronous I/o notification mechanism (such as epoll) trigger Completion Dispatch, Http Handler to perform again
Figure 6 Web browser to access a Proactor pattern of the Web Server process.And Reactor time-consuming IO operations to the operating system is the main difference between asynchronous I/o library (such as GNU/Linux aio), operating system, asynchronous I/o library after the execution by asynchronous I/o notification mechanism (such as epoll) trigger Completion Dispatch, Http Handler to perform again
In fact, Vert. X/Reactor to realize part of Netty is in Netty 4.0 as shown in the above code implementation, and the figure can correspond to a few classes is io.net ty. Channel. Nio. NioEventLoop, io.net ty. Channel. Epoll. EpollEventLoop, Java. Nio. Channels. Spi. SelectorProvide.
Vert. X3.0 updates
Vert. X3.0 is Vert. X2. Major upgrade of x, is not only a package from org. Vertx to IO. The replacement of comprehensive vertx, some important core classes also have done damage type of reconstruction, from Vert. It's almost impossible to x2 program to upgrade to the Vert. X3.0 program.Suggest for the new project directly from the Vert. X3.0 began.The following is a Vert. X3 features to upgrade:
; Vert. X2. X remove the module in the system.The Vert. X3.0 recommend using Maven module
system, of course not only limited to Maven.Support other languages in Vert. X code generation;
; Vert. X3.0 project build, from Gradle Maven instead;In order to better use Java8 Lambdas, only
support Java8;The default use flat classpath structure;
; Way to simplify the Verticle factory;Support with a programming way, instantiate the Verticle and
deployment Verticle instance;When you are blocking the Eventloop warning when the main thread,
blocking Reactor main thread is a kind of wrong way;Remove PlatformManager module;Cluster
management can be used programmatically call support sharing data between cluster
nodes;Completely rewrote the HTTPclient, more perfect;
; WebSocketAPI improvement;
; The improvement of the SSL/TLS;
; Eventbus API to improve;
; Support the Eventbus agent;Increase the extension project set 'ext stack; ; Increased the MongoService, support mongo's pure asynchronous drive; ; Achieve ReactiveStreams;
; Implementation of reactive - streams;
; Can support the use of the Options class, the constructor parameters in;