因为我是骆驼的初学者。我想得到一个提示来解决我的问题。以下是我的代码
完整源码链接:https://github.com/kcy0142/camel_netty_test
@Configuration
public class ChannelHandlerFactoryByteArrayDecoder implements ChannelHandlerFactory {
@Bean(name="vpaByteDecoder")
@Qualifier("vpaByteDecoder")
public ChannelHandler newChannelHandler() {
return (ChannelHandler) new VpaByteDecoder();
}
public class VpaByteDecoder extends ByteToMessageDecoder{
}
}我的路由器是
from("netty4:tcp://localhost:8004?textline=true&sync=true&decoders=#vpaByteDecoder&encoders=#stringEncoder").错误是这样调用的
io.netty.channel.ChannelPipelineException: config.ChannelHandlerFactoryDecoder$VpaByteDecoder is not a @Sharable handler, so can't be added or removed multiple times.ByteToMessageDecoder不应共享。所以我实现了ChannelHandlerFactory
我不知道reason.plaease告诉我理解我的问题的方法。
发布于 2017-07-07 15:17:16
它是应该命名的工厂类,而不是bean方法,如下所示,并删除@Bean
@Component(name="vpaByteDecoder")
public class ChannelHandlerFactoryByteArrayDecoder implements ChannelHandlerFactory {https://stackoverflow.com/questions/44961587
复制相似问题