Hello,

I am currently implementing a bridge between two system and trying to figure
out how to achieve the following:
I have a single connection to a message provider which multiplexes its
messages. Those messages need to be de-multiplexed, processed in a asynch'd
fashion and sent to a server for processing.

broker =(single connection)=> bridge =(multiple connection) => server

I have written my ProtocolCodecFilter which works nicely and used
a DemuxingIoHandler to handle the different de-multiplexed messages. Where I
am stumbling is how do I handle those de-multiplexed message in a asynch
manner that will not block incoming messages from the broker (while the
bridge queries the server). Here is a sample of what I did:

DemuxingIoHandler demuxHandler = new DemuxingIoHandler();
 GatewayInternalHandler gatewayInternal = new GatewayInternalHandler();
GatewayRequestHandler gatewayRequest = new GatewayRequestHandler();
 GatewayUpHandler gatewayUp = new GatewayUpHandler();
 demuxHandler.addMessageHandler(GatewayInternal.class, gatewayInternal);
 demuxHandler.addMessageHandler(GatewayRequest.class, gatewayRequest);
demuxHandler.addMessageHandler(GatewayUp.class, gatewayUp);
 demuxHandler.addMessageHandler(HeaderRequest.class, MessageHandler.NOOP );
demuxHandler.addMessageHandler(HeaderResponse.class, MessageHandler.NOOP );
                 SocketAcceptor acceptor = new SocketAcceptor();
DefaultIoFilterChainBuilder filterChainBuilder =
acceptor.getDefaultConfig().getFilterChain();
 filterChainBuilder.addLast("protocol", new ProtocolCodecFilter(new
HeaderCodecFactory(false)));
acceptor.bind(new InetSocketAddress(PORT), demuxHandler);

Basically, I would like to multithread the message handlers (each handler
call gets it's own thread with its session which writes to the same pipe).
How can I achieve this ?
Thanks !
Patrick S.

Reply via email to