public void read ( final byte [ ] messageBytes , final MultiObserver observer ) { try ( final InputStream inputStream = new ByteArrayInputStream ( messageBytes ) ) { // Binary decoder for both the header and the message. final BinaryDecoder decoder = DecoderFactory . get ( ) . binaryDecoder ( inputStream , null ) ; // Read the header message. final Header header = this . headerReader . read ( null , decoder ) ; final String classId = header . getClassName ( ) . toString ( ) ; LOG . log ( Level . FINEST , "Deserializing Avro message: {0}" , classId ) ; // Get the appropriate deserializer and deserialize the message. final IMessageDeserializer deserializer = this . nameToDeserializerMap . get ( classId ) ; if ( deserializer != null ) { deserializer . deserialize ( decoder , observer , header . getSequence ( ) ) ; } else { throw new RuntimeException ( "Request to deserialize unknown message type: " + classId ) ; } } catch ( final IOException e ) { throw new RuntimeException ( "Failure reading message" , e ) ; } catch ( final InvocationTargetException | IllegalAccessException e ) { throw new RuntimeException ( "Error deserializing message body" , e ) ; } }
Read a message from the input byte stream and send it to the event handler .