- 授权协议: Apache
- 开发语言: Java
- 操作系统: 跨平台
- 软件首页: https://github.com/ReactiveX/RxNetty
软件介绍
RxNetty 是 Netty 响应式扩展(Rx) 适配器。
代码示例:
import io.netty.buffer.ByteBuf;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.reactivex.netty.RxNetty;
import io.reactivex.netty.protocol.http.server.HttpServer;
import java.nio.charset.Charset;
public final class RxNettyExample {
public static void main(String... args) throws InterruptedException {
HttpServer<ByteBuf, ByteBuf> server = RxNetty.createHttpServer(8080, (request, response) -> {
System.out.println("Server => Request: " + request.getPath());
try {
if ("/error".equals(request.getPath())) {
throw new RuntimeException("forced error");
}
response.setStatus(HttpResponseStatus.OK);
response.writeString("Path Requested =>: " + request.getPath() + '\n');
return response.close();
} catch (Throwable e) {
System.err.println("Server => Error [" + request.getPath() + "] => " + e);
response.setStatus(HttpResponseStatus.BAD_REQUEST);
response.writeString("Error 500: Bad Request\n");
return response.close();
}
});
server.start();
RxNetty.createHttpGet("http://localhost:8080/")
.flatMap(response -> response.getContent())
.map(data -> "Client => " + data.toString(Charset.defaultCharset()))
.toBlocking().forEach(System.out::println);
RxNetty.createHttpGet("http://localhost:8080/error")
.flatMap(response -> response.getContent())
.map(data -> "Client => " + data.toString(Charset.defaultCharset()))
.toBlocking().forEach(System.out::println);
RxNetty.createHttpGet("http://localhost:8080/data")
.flatMap(response -> response.getContent())
.map(data -> "Client => " + data.toString(Charset.defaultCharset()))
.toBlocking().forEach(System.out::println);
server.shutdown();
}
}输出:
Server => Request: / Client => Path Requested =>: / Server => Request: /error Server => Error [/error] => java.lang.RuntimeException: forced error Client => Error 500: Bad Request Server => Request: /data Client => Path Requested =>: /data
大数据技术原理与应用
林子雨 / 人民邮电出版社 / 2015-8-1 / 45.00
大数据作为继云计算、物联网之后IT行业又一颠覆性的技术,备受关注。大数据处不在,包括金融、汽车、零售、餐饮、电信、能源、政务、医疗、体育、娱乐等在内的社会各行各业,都融入了大数据的印迹,大数据对人类的社会生产和生活必将产生重大而深远的影响。 大数据时代的到来,迫切需要高校及时建立大数据技术课程体系,为社会培养和输送一大批具备大数据专业素养的高级人才,满足社会对大数据人才日益旺盛的需求。本书定......一起来看看 《大数据技术原理与应用》 这本书的介绍吧!
