public final class Message extends Object implements Cloneable, Serializable, Streamable, Encodable
Message
data structure.Modifier and Type | Field and Description |
---|---|
static int |
ADMIN
A admin message carries a streamable object.
|
byte[] |
body
Body of the message.
|
static int |
BYTES
A bytes message carries an array of bytes.
|
String |
clientID
The client connection identification
|
boolean |
compressed
true if compressed body. |
int |
compressedMinSize
If the message body is upper than the
compressedMinSize ,
this message body is compressed. |
int |
compressionLevel |
String |
correlationId
The correlation identifier field.
|
private static short |
corrrelationIdFlag |
static int |
DEFAULT_DELIVERY_MODE |
static int |
DEFAULT_PRIORITY |
static long |
DEFAULT_TIME_TO_LIVE |
int |
deliveryCount
The number of delivery attempts for this message.
|
private static short |
deliveryCountFlag |
long |
deliveryTime
the message delivery time value.
|
long |
expiration
The message expiration time, by default 0 for infinite time-to-live.
|
private static short |
expirationFlag |
String |
id
The message identifier.
|
String |
jmsType
The JMSType header field contains a message type identifier supplied by a
client when a message is sent.
|
private static short |
jmsTypeFlag |
static org.objectweb.util.monolog.api.Logger |
logger
logger
|
static int |
MAP
A map message carries an hashtable.
|
static int |
NON_PERSISTENT |
static int |
OBJECT
An object message carries a serializable object.
|
boolean |
persistent
true if the message must be persisted. |
static int |
PERSISTENT |
private static short |
persistentFlag |
int |
priority
The message priority from 0 to 9, 9 being the highest.
|
private static short |
priorityFlag |
Properties |
properties
The message properties table.
|
private static short |
propertiesFlag |
boolean |
redelivered
true if the message has been denied at least once by a
consumer. |
private static short |
redeliveredFlag |
String |
replyToId
The reply to destination identifier.
|
private static short |
replyToIdFlag |
String |
replyToName
The reply to destination name.
|
byte |
replyToType
true if the "reply to" destination is a queue. |
private static long |
serialVersionUID
define serialVersionUID for interoperability
|
static int |
SIMPLE
A simple message carries an empty body.
|
static int |
STREAM
A stream message carries a bytes stream.
|
static int |
TEXT
A text message carries a String body.
|
long |
timestamp
The message time stamp.
|
String |
toId
The message destination identifier.
|
String |
toName
The message destination name.
|
byte |
toType
The message destination type.
|
int |
type
The client message type: SIMPLE, TEXT, OBJECT, MAP, STREAM, BYTES, ADMIN.
|
private static short |
typeFlag |
BOOLEAN_ENCODED_SIZE, BYTE_ENCODED_SIZE, DOUBLE_ENCODED_SIZE, FLOAT_ENCODED_SIZE, INT_ENCODED_SIZE, LONG_ENCODED_SIZE, SHORT_ENCODED_SIZE
Constructor and Description |
---|
Message()
Constructs a bright new
Message . |
Modifier and Type | Method and Description |
---|---|
void |
clearBody()
set body = null
|
Object |
clone()
Clones the message.
|
static byte[] |
compress(byte[] toCompress,
int compressionLevel)
compress byte array
|
void |
decode(Decoder decoder)
Decodes the content of this object
|
static Vector<Message> |
decodeMessageVector(Decoder decoder) |
void |
encode(Encoder encoder)
Encodes the content of this object
|
static void |
encodeMessageVector(Vector<Message> messages,
Encoder encoder) |
private Serializable |
fromBytes(byte[] body)
convert byte[] to serializable object
|
AbstractAdminMessage |
getAdminMessage()
Returns the AbstractAdminMessage body of the message.
|
byte[] |
getBody()
get the body
Uncompress if compressed
|
int |
getBodyLength() |
int |
getEncodableClassId()
Returns a unique class identifier.
|
int |
getEncodedSize()
Returns the size of the byte array that results
from the encoding of this object.
|
static int |
getMessageVectorEncodedSize(Vector<Message> messages) |
Serializable |
getObject()
Returns the object body of the message.
|
Object |
getProperty(String name)
Returns a property as an object.
|
String |
getText()
Returns the text body of the message.
|
boolean |
isNullBody() |
void |
readFrom(InputStream is)
The object implements the readFrom method to restore its contents from
the input stream.
|
void |
readHeaderFrom(InputStream is) |
private void |
readObject(ObjectInputStream in) |
static Vector |
readVectorFrom(InputStream is)
this method allows to read from the input stream a vector of messages.
|
void |
setAdminMessage(AbstractAdminMessage adminMsg)
Sets an AbstractAdminMessage as the body of the message.
|
void |
setBody(byte[] body)
set the body.
|
void |
setDestination(String id,
String name,
byte type)
Sets the message destination.
|
void |
setObject(Serializable object)
Sets an object as the body of the message.
|
void |
setProperty(String name,
Object value)
Sets a property value.
|
void |
setReplyTo(String id,
String name,
byte type)
Sets the destination to which a reply should be sent.
|
void |
setText(String text)
Sets a String as the body of the message.
|
private byte[] |
toBytes(Serializable object)
convert serializable object to byte[]
|
String |
toString() |
void |
toString(StringBuffer strbuf) |
static byte[] |
uncompress(byte[] toUncompress)
Uncompress byte array
|
void |
writeHeaderTo(OutputStream os) |
private void |
writeObject(ObjectOutputStream out)
***** ***** ***** ***** ***** ***** *****
Serializable interface
***** ***** ***** ***** ***** ***** ***** *****
|
void |
writeTo(OutputStream os)
The object implements the writeTo method to write its contents to
the output stream.
|
static void |
writeVectorTo(Vector messages,
OutputStream os)
this method allows to write to the output stream a vector of message.
|
private static final long serialVersionUID
public static final int NON_PERSISTENT
public static final int PERSISTENT
public static final int DEFAULT_DELIVERY_MODE
public static final int DEFAULT_PRIORITY
public static final long DEFAULT_TIME_TO_LIVE
public static org.objectweb.util.monolog.api.Logger logger
public transient byte[] body
public transient Properties properties
public transient String id
public transient boolean persistent
true
if the message must be persisted.public static final int SIMPLE
public static final int TEXT
public static final int OBJECT
public static final int MAP
public static final int STREAM
public static final int BYTES
public static final int ADMIN
public transient int type
public transient String jmsType
public transient int priority
public transient long expiration
public transient long timestamp
public transient boolean redelivered
true
if the message has been denied at least once by a
consumer.public transient String toId
public transient String toName
public transient byte toType
public transient boolean compressed
true
if compressed body.public transient int compressedMinSize
compressedMinSize
,
this message body is compressed.public transient int compressionLevel
public transient long deliveryTime
public transient String clientID
public transient String replyToId
public transient String replyToName
public transient byte replyToType
true
if the "reply to" destination is a queue.public transient String correlationId
public transient int deliveryCount
private static final short typeFlag
private static final short replyToIdFlag
private static final short propertiesFlag
private static final short priorityFlag
private static final short expirationFlag
private static final short corrrelationIdFlag
private static final short deliveryCountFlag
private static final short jmsTypeFlag
private static final short redeliveredFlag
private static final short persistentFlag
public Object getProperty(String name)
name
- The property name.public void setProperty(String name, Object value)
name
- The property name.value
- The property value.IllegalArgumentException
- If the key name is illegal (null or empty string).public final void setDestination(String id, String name, byte type)
id
- The destination identifier.name
- The destination name.type
- The type of the destination.public final void setReplyTo(String id, String name, byte type)
id
- The destination identifier.type
- The destination type.private byte[] toBytes(Serializable object) throws IOException
object
- the serializable objectIOException
- In case of errorprivate Serializable fromBytes(byte[] body) throws Exception
body
- the byte arrayException
- In case of errorpublic void setText(String text) throws IOException
IOException
- In case of an error while setting the textpublic String getText() throws Exception
Exception
- In case of an error while getting the textpublic void setObject(Serializable object) throws IOException
IOException
- In case of an error while setting the object.public Serializable getObject() throws Exception
Exception
- In case of an error while getting the object.public void setAdminMessage(AbstractAdminMessage adminMsg) throws IOException
IOException
- In case of an error while setting the object.public AbstractAdminMessage getAdminMessage()
IOException
- In case of an error while getting the object.ClassNotFoundException
- If the object class is unknown.public void setBody(byte[] body) throws IOException
body
- a byte arrayIOException
- if an I/O error has occurredpublic byte[] getBody() throws IOException
IOException
- if an I/O error has occurredpublic void clearBody()
public boolean isNullBody()
public int getBodyLength()
public static byte[] compress(byte[] toCompress, int compressionLevel) throws IOException
toCompress
- a byte array to compressIOException
- if an I/O error has occurredpublic static byte[] uncompress(byte[] toUncompress) throws IOException
toUncompress
- a compressed byte arrayIOException
- if an I/O error has occurredpublic void toString(StringBuffer strbuf)
public void writeTo(OutputStream os) throws IOException
writeTo
in interface Streamable
os
- the stream to write the object toIOException
public void writeHeaderTo(OutputStream os) throws IOException
IOException
public void readFrom(InputStream is) throws IOException
readFrom
in interface Streamable
is
- the stream to read data from in order to restore the objectIOException
public void readHeaderFrom(InputStream is) throws IOException
IOException
public static void writeVectorTo(Vector messages, OutputStream os) throws IOException
messages
- the vector of messagesos
- the stream to write the vector toIOException
public static Vector readVectorFrom(InputStream is) throws IOException
is
- the stream to read data from in order to restore the vectorIOException
private void writeObject(ObjectOutputStream out) throws IOException
IOException
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
ClassNotFoundException
IOException
public int getEncodableClassId()
Encodable
getEncodableClassId
in interface Encodable
public int getEncodedSize() throws Exception
Encodable
getEncodedSize
in interface Encodable
Exception
- if an error occurspublic void encode(Encoder encoder) throws Exception
Encodable
public void decode(Decoder decoder) throws Exception
Encodable
public static int getMessageVectorEncodedSize(Vector<Message> messages) throws Exception
Exception
public static void encodeMessageVector(Vector<Message> messages, Encoder encoder) throws Exception
Exception
Copyright © 2013 ScalAgent D.T.. All Rights Reserved.