相关疑难解决方法(0)

netty的并发编码

编码器的编码方法会同时执行吗?我观察到编码方法可能由不同的线程并发.管道定义为:

Channels.pipeline(
    idleHandler,
    new AmfDecoder<GameEvent>(GameEvent.class),
    new AmfEncoder<GameEvent>(),
    concurrencyHandler,
    new WebHandler());
Run Code Online (Sandbox Code Playgroud)

编码器:

public class AmfEncoder<T extends IAmfEvent> extends OneToOneEncoder{
private final SerializationContext serializationContext = new SerializationContext();
private final Amf3Output amfout = new Amf3Output(serializationContext);

@Override
protected Object encode(ChannelHandlerContext arg0, Channel arg1,
        Object arg2) throws Exception {
    T e = (T)arg2;
    ByteArrayOutputStream byteoutStreamSize = new ByteArrayOutputStream();
    amfout.setOutputStream(byteoutStreamSize);
    amfout.writeObject(e.getBody());
    // byteoutStreamSize has small probability become empty at here, in debug mode I can sure e.getBody() has data
    // I thought byteoutStreamSize might be empty …
Run Code Online (Sandbox Code Playgroud)

java concurrency netty

2
推荐指数
1
解决办法
1698
查看次数

随时向客户端发送消息 Netty Io

我有一个基于微服务的架构,netty io 在 spring boot 应用程序上运行,当我想向客户端发送消息时,我必须等待来自客户端的消息将回复发送给我想要发送的人。如何在不等待他与我沟通的情况下向客户发送消息?我迷失在这一步。

java netty server

2
推荐指数
1
解决办法
2171
查看次数

标签 统计

java ×2

netty ×2

concurrency ×1

server ×1