@ Override public void messageReceived ( T message ) { if ( responseReceived != null ) { if ( responseReceived ) { log . warn ( "Received more than one synchronous message reply!" ) ; } else { log . warn ( "Received response message after timeout was hit!" ) ; } } responseMessage = message ; responseReceived = true ; synchronized ( lock ) { lock . notify ( ) ; } }
When we get our expected message response . Save the message object and notify the waiting thread that the message is now available to be passed back . This method attempts to handle and warn against cases where multiple messages came in or a message came in after the timeout period .