org.mule.transport.tcp.protocols
Class LengthProtocol
java.lang.Object
org.mule.transport.tcp.protocols.AbstractByteProtocol
org.mule.transport.tcp.protocols.DirectProtocol
org.mule.transport.tcp.protocols.LengthProtocol
- All Implemented Interfaces:
- TcpProtocol
- Direct Known Subclasses:
- MuleMessageLengthProtocol
public class LengthProtocol
- extends DirectProtocol
The LengthProtocol is an application level tcp protocol that can be used to
transfer large amounts of data without risking some data to be loss. The protocol
is defined by sending / reading an integer (the packet length) and then the data
to be transferred.
Note that use of this protocol must be symmetric - both the sending and receiving
connectors must use the same protocol.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NO_MAX_LENGTH
public static final int NO_MAX_LENGTH
- See Also:
- Constant Field Values
LengthProtocol
public LengthProtocol()
LengthProtocol
public LengthProtocol(int maxMessageLength)
read
public Object read(InputStream is)
throws IOException
- Description copied from interface:
TcpProtocol
- Reads the input stream and returns a whole message.
- Specified by:
read
in interface TcpProtocol
- Overrides:
read
in class DirectProtocol
- Parameters:
is
- the input stream
- Returns:
- an array of byte containing a full message
- Throws:
IOException
- if an exception occurs
writeByteArray
protected void writeByteArray(OutputStream os,
byte[] data)
throws IOException
- Overrides:
writeByteArray
in class AbstractByteProtocol
- Throws:
IOException
isRepeat
protected boolean isRepeat(int len,
int available)
- Read all four bytes for initial integer (limit is set in read)
- Overrides:
isRepeat
in class DirectProtocol
- Parameters:
len
- Amount transferred last call (-1 on EOF or socket error)available
- Amount available
- Returns:
- true if the transfer should continue
getMaxMessageLength
public int getMaxMessageLength()
setMaxMessageLength
public void setMaxMessageLength(int maxMessageLength)
Copyright © 2003-2009 MuleSource, Inc.. All Rights Reserved.