mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hieu Phan Thanh" <hie...@Cybersoft-VN.com>
Subject Message was not fired to the last filter "IoHandler" - Deadlock
Date Mon, 11 Dec 2006 09:15:30 GMT
Hi everybody,

I have got a problem around the "message fired" method.
After receiving some message successfully, the application is deadlock
after the "decode" method was returned, that mean the application could
not call the "messageReceived" method.
Any help is very highly appreciated.

Thanks, Hieu Phan.

Here are some details about the application:

--getSession method START------------
	public synchronized static IoSession getSession() {
		appendDebugLog("Trying to connect to K/S Station...",
true);
		
		// Change the worker timeout to 1 second to make the I/O
thread quit
		// soon
		// when there's no connection to manage.
		connector.setWorkerTimeout(1);
		
		// Configure the service.
		SocketConnectorConfig cfg = new SocketConnectorConfig();
		cfg.setConnectTimeout(CONNECT_TIMEOUT);
		
		cfg.getFilterChain().addLast("codec",
				new ProtocolCodecFilter(new
BcClientProtocolCodecFactory()));

		Executor protocolExecutor =
Executors.newFixedThreadPool(SysConfig.MAX_IO_THREAD_POOL);
		cfg.getFilterChain().addLast("threadpool", 
				new ExecutorFilter(protocolExecutor));
		
		IoSession session;

		try {
			ConnectFuture future = connector.connect(new
InetSocketAddress(
					KS_SERVER, KS_PORT), new
BcClientSessionHandler(), cfg);

			future.join();
			session = future.getSession();
			
			appendDebugLog("Connect to K/S Station
successfully.", true);
		} catch (RuntimeIOException e) {
			appendInfoLog("Could not connect to K/S
Station.", true);
			session = null;			
		}

		return session;
	}
--getSession method END------------

--decode method START--------------
	public MessageDecoderResult decode(IoSession session, ByteBuffer
in,
			ProtocolDecoderOutput out) throws Exception {
		logger.debug("[DECODER] decoding AckMessage...");
		
		AckBcMessage ackMessage = new AckBcMessage();
		
		try {
			ackMessage.setReceivedMsgSize(in.getString(10, 
					Constants.CHARSET_DECODER));
		} catch (CharacterCodingException e) {		
			logger.error("DECODER] Exception: ", e);
		}

		logger.debug("ACK = " + ackMessage);
		out.write(ackMessage);
		logger.debug("[DECODER] decoding AckMessage is
completed.");
		return MessageDecoderResult.OK;
	}
--decode method END--------------


Mime
View raw message