首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >camel netty4 ChannelHandlerFactory ByteToMessageDecoder错误

camel netty4 ChannelHandlerFactory ByteToMessageDecoder错误
EN

Stack Overflow用户
提问于 2017-07-07 10:22:40
回答 1查看 238关注 0票数 0

因为我是骆驼的初学者。我想得到一个提示来解决我的问题。以下是我的代码

完整源码链接:https://github.com/kcy0142/camel_netty_test

代码语言:javascript
复制
@Configuration
public class ChannelHandlerFactoryByteArrayDecoder implements ChannelHandlerFactory {

    @Bean(name="vpaByteDecoder")
    @Qualifier("vpaByteDecoder")
    public ChannelHandler newChannelHandler() {
      return (ChannelHandler) new VpaByteDecoder();
    }
    public  class VpaByteDecoder extends ByteToMessageDecoder{

    }
}

我的路由器是

代码语言:javascript
复制
from("netty4:tcp://localhost:8004?textline=true&sync=true&decoders=#vpaByteDecoder&encoders=#stringEncoder").

错误是这样调用的

代码语言:javascript
复制
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告诉我理解我的问题的方法。

EN

回答 1

Stack Overflow用户

发布于 2017-07-07 15:17:16

它是应该命名的工厂类,而不是bean方法,如下所示,并删除@Bean

代码语言:javascript
复制
@Component(name="vpaByteDecoder")
public class ChannelHandlerFactoryByteArrayDecoder implements ChannelHandlerFactory {
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44961587

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档