2016-11-02 66 views
0

親愛的駱駝/阿卡/內蒂大師!Akka +駱駝+情境提供者

我創建UntypedConsumerActor消耗TCP連接:

public class TcpEndpoint extends UntypedConsumerActor { 

    private static final Logger log = LoggerFactory.getLogger(TcpEndpoint.class); 

    public static Props props = Props.create(TcpEndpoint.class); 

    @Override 
    public String getEndpointUri() { 
     return "netty4:tcp://localhost:8000?decoders=#fdDecoder,#fdHandler"; 
    } 

    @Override 
    public void onReceive(Object message) throws Throwable { 
     log.error("onReceived"); 
    } 

} 

如果配置爲網狀組件解碼器,我已經創建ContextProvider:

public class FDCamelContext implements ContextProvider { 

    public DefaultCamelContext getContext(ExtendedActorSystem system) { 
     JndiRegistry registry = new JndiRegistry(); 
     registry.bind("fdDecoder", new FDDecoder()); 
     registry.bind("fdHandler", new FDHandler()); 

     DefaultCamelContext context = new DefaultCamelContext(registry); 
     return context; 
    } 
} 

現在,當我有發短信onReceive方法沒有調用。爲什麼?當我設置DefaultContextProvider並將netty配置爲使用文本行時,所有操作都按預期工作。

回答

1

好吧,我發現問題。也許這可以幫助別人:

這是necesarry火channelRead事件:

ctx.fireChannelRead(msg);