- 浏览: 156210 次
文章分类
最新评论
-
飘零雪:
[b][/b][i][/i][u][/u]引用
自定义Mave archetype的创建 -
fujohnwang:
<div class="quote_title ...
基于iBatis的开源分布式数据访问层 -
gzenzen:
<pre name="code" c ...
基于iBatis的开源分布式数据访问层 -
fujohnwang:
bornwan 写道我就很想知道分布式数据源,水平切分之后排序 ...
基于iBatis的开源分布式数据访问层 -
fujohnwang:
gzenzen 写道什么时候支持mybatis3、spring ...
基于iBatis的开源分布式数据访问层
王福强(Darren.Wang)
<fujohnwang@gmail.com
>
-
annotation doesn't effect anything, pipeline factory do!
-
always provide your own PipelineFactory so that others can see your pipeline overview; add java doc(@see) in your ChannelHandler to point to the PipelineFactory definition class for further documentation;
-
prevent re-invent the wheels that has been available;(Since Netty has provided lot of available ChannelHandler implementations we can use.)
-
pay attention to event-driven attribute of Netty, simply put, the "messageReceived" method will be invoked multiple times, so take care of the state of your data carefully.
-
use LoggingHandler to debug.
LoggingHandler use JDK logging as default logging facility. If we want to change to use other ones, we need invoke InternalLoggingFactory.setDefaultFactory(..) before any netty classes are loaded. for example, if we want to use slf4j logging facility:
InternalLoggingFactory.setDefaultFactory(new Slf4JLoggingFactory();
-
You have to invoke channel.close() in another thread other than the IOWorker thread.
public void exceptionCaught(final ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { new Thread(){ public void run(){ ctx.getChannel().close().addListener(new ChannelFutureListener() { public void operationComplete(ChannelFuture future) throws Exception { future.awaitUninterruptibly(); getBoostrap().releaseExternalResources(); logger.debug("shutdown"); } }); } }.start(); }
-
use IdleStateHandler and IdleStateAwareChannelHandler together to achieve some functionalities like connection status checking, long-push server mocks, etc.
Note
use a global Timer to share between all of you IdleStateHandlers instead of creating each for them. A Timer can suffice because of its implementation mechanism(TimerWheel).
-
always set “connectTimeoutMillis” connection option to achieve timeout return. without this option, future.awaitUninterruptibly(timeoutValue) means less.
-
More...
-
在使用ChannelBuffer的readBytes和getBytes的时候要注意index的意义不同.
例 如: 当前ChannelBuffer中有10个byte, 你通过readBytes读取了4个, 然后, 想查看一下下一个byte的值, 那么,你可以通过readByte()方法, 然后resetReaderIndex(); 或者, 你可以通过getByte(4)来peek这个值, 这里要注意的就是, getByte传入的index是最初的ChannelBuffer开始位置进行计算, 而不是剩余的bytes的位置进行计算. 即不是getByte(0).
-
@ChannelPipelineCoverage("one") Annotation doesn’t mean too much. It only works as a tip, nothing more. If you think you mark a ChannelHandler with “one” and Netty will use the ChannelHandler as a prototype, then you are wrong. It’s still your responsibility to ensure the scope semantics of singleton and prototype.
-
在ChannelHandler中, 通过exceptionCaught方法再次将异常抛出以期望更上层来处理是没有前途的。 因为这种情况下抛出的异常将只是由DefaultChannelPipeline记录一条warning的日志,仅此而已, 你无法进一步插足该异常的处理。
另选方案可能是, 在exceptionCaught方法中将要抛出以交给其他对象处理的异常放入某个共享状态中, 比如某个queue, 然后, 对这些异常感兴趣的对象可以对该队列进行轮询以处理之。
- More...
发表评论
-
基于iBatis的开源分布式数据访问层
2011-03-28 11:46 5533http://code.alibabatech.com/wik ... -
分布式数据访问与同步场景浅析
2010-09-06 19:50 2234分布式数据访 ... -
有关Maven编译DeprecatedAPI失败的问题
2010-08-02 10:59 4467在项目代码里用了sun.misc.Signal ... -
Java Daemon Control
2010-07-27 17:50 2901Java Daemon Control ... -
Event Driven Style API Design Instead of Old Procedure Style Ones
2010-07-12 19:53 1469王福强(Darren.Wang) <f ... -
HA狭义与广义论
2010-07-09 09:25 1460Author: Darren Wang(fujohnwang) ... -
Why We Need A Global ID Generator?!
2010-05-18 13:01 1620Table of Contents 1. Pai ... -
Gotchas With JUnit's Execution Model
2010-03-26 09:22 1045Maybe you have known it before, ... -
Transaction Management Patterns In Brief
2010-02-09 10:27 1761There are several patte ... -
"扩展Spring的依赖注入行为"两例
2009-12-26 12:59 2726扩展Spring的依赖注入行为两例 ... -
框架API设计相关的碎言
2009-11-17 09:32 1606框架的API设计,应该是 ... -
自定义Mave archetype的创建
2009-10-29 20:12 12349Table of Contents ... -
看来有人已经有要抢先推出这个节目的意思了
2009-10-27 19:29 1014这篇blog对java, clojure和scala中的并发处 ... -
Roma Documentation Outline
2009-10-27 17:35 150Roma Docume ... -
Hot Stuff - Lombok
2009-10-22 19:46 1024give it a try, it's really cool ... -
ROMA框架潜在改进点思考(Thinking in ROMA improvements)
2009-10-21 19:53 1931. 关于ROMA现有表单 ... -
Valang Validator under the hood
2009-10-19 13:29 1657Table of Contents 1. Va ... -
ThreadSafety, Non-ThreadSafety 与 Stateless, Stateful有必然的对应关系吗?
2009-10-09 09:11 1855“It depends. ” 我们 ... -
A Big Piture On Concurrency
2009-09-12 09:49 12353- Concurrency Share (Concur ... -
尴尬的COC
2009-08-25 11:04 992Convention Over Configurati ...
相关推荐
Netty in Action introduces the Netty framework and shows you how to incorporate it into your Java network applications. You'll learn to write highly scalable applications without the need to dive into...
Netty is a Java-based networking framework designed to handle asynchronous network events smoothly so your applications are easy to write and maintain. The framework hides all the boilerplate and low...
Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients. It greatly simplifies and streamlines network programming ...
Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients. It greatly simplifies and streamlines network programming ...
Netty is a Java-based networking framework designed to handle asynchronous network events smoothly so your applications are easy to write and maintain. The framework hides all the boilerplate and low...
Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients. It greatly simplifies and streamlines network programm ...
Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients. It greatly simplifies and streamlines network programm ing
Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients. It greatly simplifies and streamlines network programming ...
Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients. It greatly simplifies and streamlines network programming
Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients. It greatly simplifies and streamlines network programming ...
《Netty实战》这本书是针对Java网络编程框架Netty的一本深入实践教程,旨在帮助读者掌握Netty的核心特性和实际应用。Netty是一款高性能、异步事件驱动的网络应用程序框架,广泛应用于各种分布式系统、微服务架构以及...
Netty基础,用于学习Netty,参考黑马程序员的netty教程
《Netty实战》是针对Java开发者的一本技术指南,它深入介绍了如何利用Netty这个高性能、异步事件驱动的网络应用程序框架来构建高效且可扩展的网络应用。Netty不仅简化了网络编程的复杂性,还提供了丰富的特性和组件...
《跟闪电侠学Netty:Netty即时聊天实战与底层原理》是一本深入浅出的Netty技术指南,旨在帮助读者掌握Netty框架,并利用它实现即时聊天应用,同时理解其底层工作原理。Netty是Java领域的一款高性能、异步事件驱动的...
《Netty进阶之路-跟着案例学Netty》是由知名技术专家李林峰撰写的一本专为Java开发者深入理解Netty框架而准备的书籍。这本书旨在通过实例教学,帮助读者全面掌握Netty的核心特性和实战技巧,提升网络编程的能力。 ...
在SpringBoot项目中,我们可以通过添加对应的依赖来引入Netty,例如在`pom.xml`中加入`spring-boot-starter-webflux`,这个依赖集成了Reactor Netty,它是Spring Framework 5.x对响应式编程的支持,底层就是基于...
Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients. It greatly simplifies and streamlines network programming ...