Netty
Netty is _an asynchronous event-driven network application framework _for rapid development of maintainable high performance protocol servers & clients. -- https://netty.io
Hello world
Lets create a simple HTTP server using Netty.
Fist lets get the dependencies using Gradle.
plugins {
id 'java'
id 'application'
}
ext {
vertxVersion = '3.5.0'
}
repositories {
mavenLocal()
jcenter()
}
version = '1.0.0-SNAPSHOT'
sourceCompatibility = '1.8'
dependencies {
compile 'io.netty:netty-all:5.0.0.Alpha2'
}
mainClassName = 'com.example.demo.NettyApp'
task wrapper(type: Wrapper) {
gradleVersion = '4.0'
}Now lets create code needed to handle request using Netty.
Now we can compare code required to start HTTP server using Netty and "couple" of lines required by Vert.x.
When we run the server and call curl localhost:8888 then we will see these logs.
The curl returns Hello World message we have implemented in HttpServerHandler.
Last updated
Was this helpful?