Package org.apache.catalina.tribes
Class ByteMessage
- java.lang.Object
-
- org.apache.catalina.tribes.ByteMessage
-
- All Implemented Interfaces:
java.io.Externalizable
,java.io.Serializable
public class ByteMessage extends java.lang.Object implements java.io.Externalizable
A byte message is not serialized and deserialized by the channel instead it is sent as a byte array
By default Tribes uses java serialization when it receives an object to be sent over the wire. Java serialization is not the most efficient of serializing data, and Tribes might not even have access to the correct class loaders to deserialize the object properly.
The ByteMessage class is a class where the channel when it receives it will not attempt to perform serialization, instead it will simply stream thegetMessage()
bytes.
If you are using multiple applications on top of Tribes you should add some sort of header so that you can decide with theChannelListener.accept()
whether this message was intended for you.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ByteMessage()
Creates an empty byte message Constructor also for deserializationByteMessage(byte[] data)
Creates a byte message with
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
getMessage()
Returns the message contents of this byte messagevoid
readExternal(java.io.ObjectInput in)
void
setMessage(byte[] message)
Sets the message contents of this byte messagevoid
writeExternal(java.io.ObjectOutput out)
-
-
-
Method Detail
-
getMessage
public byte[] getMessage()
Returns the message contents of this byte message- Returns:
- byte[] - message contents, can be null
-
setMessage
public void setMessage(byte[] message)
Sets the message contents of this byte message- Parameters:
message
- byte[]
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException
- Specified by:
readExternal
in interfacejava.io.Externalizable
- Parameters:
in
- ObjectInput- Throws:
java.io.IOException
- An IO error occurred- See Also:
Externalizable.readExternal(java.io.ObjectInput)
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
- Specified by:
writeExternal
in interfacejava.io.Externalizable
- Parameters:
out
- ObjectOutput- Throws:
java.io.IOException
- An IO error occurred- See Also:
Externalizable.writeExternal(java.io.ObjectOutput)
-
-