MINA 2.0 RC1を使用してdemuxベースのクライアントアプリケーションで同期書き込み/読み取りを実行しようとしていますが、スタックしているようです。これが私のコードです:
public boolean login(final String username, final String password) {
// block inbound messages
session.getConfig().setUseReadOperation(true);
// send the login request
final LoginRequest loginRequest = new LoginRequest(username, password);
final WriteFuture writeFuture = session.write(loginRequest);
writeFuture.awaitUninterruptibly();
if (writeFuture.getException() != null) {
session.getConfig().setUseReadOperation(false);
return false;
}
// retrieve the login response
final ReadFuture readFuture = session.read();
readFuture.awaitUninterruptibly();
if (readFuture.getException() != null) {
session.getConfig().setUseReadOperation(false);
return false;
}
// stop blocking inbound messages
session.getConfig().setUseReadOperation(false);
// determine if the login info provided was valid
final LoginResponse loginResponse = (LoginResponse)readFuture.getMessage();
return loginResponse.getSuccess();
}
サーバー側で、LoginRequestオブジェクトが取得され、LoginResponseメッセージが送信されていることがわかります。クライアント側では、DemuxingProtocolCodecFactory
は応答を受信しますが、ログをスローした後、クライアントがへの呼び出しでスタックしていることがわかりますreadFuture.awaitUninterruptibly()
。
私自身のコードに基づいて、なぜそれがここで立ち往生しているのか理解することはできません。セッション構成で読み取り操作をtrueに適切に設定しました。これは、メッセージをブロックする必要があることを意味します。しかし、応答メッセージを同期的に読み取ろうとすると、メッセージが存在しなくなったように見えます。
なぜこれがうまくいかないのかについての手がかりはありますか?