gumbo.net.msg
Interface MessageReader

All Superinterfaces:
MessageIO
All Known Implementing Classes:
AsciiMessageReader, ObjectMessageReader

public interface MessageReader
extends MessageIO

Interface for reading whole messages.

Version:
$Revision: 1.6 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.

Method Summary
 void close()
          Closes this message reader.
 Message readMessage()
          Reads a message, including its end delimiter, in a thread-safe manner.
 void syncMessageEnd()
          Reads the current message to its end.
 
Methods inherited from interface gumbo.net.msg.MessageIO
addMessageIOListener, getMessageIOListeners, removeMessageIOListener
 

Method Detail

close

public void close()
           throws java.io.IOException
Closes this message reader.

java.io.IOException

readMessage

public Message readMessage()
                    throws java.io.IOException,
                           MessageIOException,
                           MessageDataException
Reads a message, including its end delimiter, in a thread-safe manner. Blocks until a message is completely received. Typically, this method is synchronized on this message reader, which is used by all threads in the application to receive messages.

Returns:
The message. Never null.
Throws:
java.io.IOException - Reader is closed.
MessageIOException - Message end not found.
MessageDataException - Message data corrupted.

syncMessageEnd

public void syncMessageEnd()
                    throws java.io.IOException,
                           MessageIOException
Reads the current message to its end. Blocks until the end is received. Ignores everything but the message end delimiter. Useful for syncing the message stream following a message exception.

Throws:
java.io.IOException - Reader is closed.
MessageIOException - Message end not found (which should never happen).