netty에서 Bootstrap 생성, 설정 한 후, connect() 를 하고 동기식으로 다음 로직을 실행할 때
원래는 외부에 connect()의 결과를 리턴 해 주기 위해 아래처럼 await 관련 메소드를 썼었는데, 이럴 경우, 하나의 프로그램에서 여러 netty클라이언트를 사용해서 처리할 경우, dead lock이 걸릴 수도 있다는 예외(?)를 netty가 친절(?)하게 알려 준다. ㅜㅜ;
// Wait until the connection attempt succeeds or fails.
logger.info("Failed connect to Server. channel["+ channel +"]");
return false;
}else {
logger.info("Success connect to Server. channel["+ channel +"]");
return true;
}
예외 메세지는 요렇다.
java.lang.IllegalStateException: await*() in I/O thread causes a dead lock or sudden performance drop. Use addListener() instead or call await*() from a different thread.
어쩌구저쩌구...
반드시 동기식으로 진행되어야 하는 상황이 아니라면 아래처럼 리스너를 등록해서 netty가 던져주는 이벤트를 받아서 처리해 주도록 한다.