在netty中向self发送消息

在netty中向self发送消息,netty,Netty,我想向netty的线程分派一个作业,如果我不这样做,我必须关心线程同步,因为作业不是由从客户端收到的消息触发的。 我发现ChannelPipeline有一个方法sendUpstream可以满足我的要求,但我无法获得所有ChannelPipeline的对象。我的意思是: // code in thread which not belong to netty's thread for(all pipeline) pipeline.sendUpstream(my_pseudo_message)

我想向netty的线程分派一个作业,如果我不这样做,我必须关心线程同步,因为作业不是由从客户端收到的消息触发的。 我发现ChannelPipeline有一个方法sendUpstream可以满足我的要求,但我无法获得所有ChannelPipeline的对象。我的意思是:

// code in thread which not belong to netty's thread
for(all pipeline)
    pipeline.sendUpstream(my_pseudo_message)

MyChannelHander.messageReceive() {
    //code to deal with my_pseudo_message
}

如果要在Netty的工作线程中执行某些操作,请使用:

channel.getPipeline().execute(new Runnable() {...});

如果我使用OrderedMemoryAwareThreadPoolExecutor呢?它仍然在I/O线程中运行吗?这不是我想要的…channel.getPipeline().execute(..)始终将您的工作放在I/O线程中。如果我使用OrderedMemoryAwareThreadPoolExecutor,请以任何方式将其分派给给定通道的ChildExecutor?因此,在使用OMATPE时,您想要“只是”确保其在给定通道的所有其他执行器中执行。。对吧?对。我希望确保没有同步问题(I/O线程可能看不到OMATPE中的数据更改),并且我不希望此作业与此通道的正常消息进程并发执行。我的业务域对象没有考虑同步。