public class ChannelData extends java.lang.Object implements ChannelMessage
ChannelData
object is used to transfer a message through the
channel interceptor stack and eventually out on a transport to be sent
to another node. While the message is being processed by the different
interceptors, the message data can be manipulated as each interceptor seems appropriate.Modifier and Type | Field and Description |
---|---|
static ChannelData[] |
EMPTY_DATA_ARRAY |
static boolean |
USE_SECURE_RANDOM_FOR_UUID |
Constructor and Description |
---|
ChannelData()
Creates an empty channel data with a new unique Id
|
ChannelData(boolean generateUUID)
Create an empty channel data object
|
ChannelData(byte[] uniqueId,
XByteBuffer message,
long timestamp)
Creates a new channel data object with data
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
bToS(byte[] data) |
java.lang.Object |
clone()
Create a shallow clone, only the data gets recreated
|
java.lang.Object |
deepclone()
Complete clone
|
boolean |
equals(java.lang.Object o)
Compares to ChannelData objects, only compares on getUniqueId().equals(o.getUniqueId())
|
void |
generateUUID()
Generates a UUID and invokes setUniqueId
|
Member |
getAddress()
Returns the source or reply-to address
|
static ChannelData |
getDataFromPackage(byte[] b) |
static ChannelData |
getDataFromPackage(XByteBuffer xbuf)
Deserializes a ChannelData object from a byte array
|
byte[] |
getDataPackage()
Serializes the ChannelData object into a byte[] array
|
byte[] |
getDataPackage(byte[] data,
int offset) |
int |
getDataPackageLength() |
XByteBuffer |
getMessage()
returns the byte buffer that contains the actual message payload
|
int |
getOptions()
The message options is a 32 bit flag set
that triggers interceptors and message behavior.
|
long |
getTimestamp()
Timestamp of when the message was created.
|
byte[] |
getUniqueId()
Each message must have a globally unique Id.
|
int |
hashCode() |
static boolean |
sendAckAsync(int options)
Utility method, returns true if the options flag indicates that an ack
is to be sent after the message has been received but not yet processed
|
static boolean |
sendAckSync(int options)
Utility method, returns true if the options flag indicates that an ack
is to be sent after the message has been received and processed
|
void |
setAddress(Member address)
Sets the source or reply-to address
|
void |
setMessage(XByteBuffer message)
The byte buffer that contains the actual message payload
|
void |
setOptions(int options)
Sets the message options.
|
void |
setTimestamp(long timestamp)
Sets the timestamp of this message
|
void |
setUniqueId(byte[] uniqueId) |
java.lang.String |
toString() |
public static final ChannelData[] EMPTY_DATA_ARRAY
public static volatile boolean USE_SECURE_RANDOM_FOR_UUID
public ChannelData()
ChannelData(boolean)
public ChannelData(boolean generateUUID)
generateUUID
- boolean - if true, a unique Id will be generatedpublic ChannelData(byte[] uniqueId, XByteBuffer message, long timestamp)
uniqueId
- - unique message idmessage
- - message datatimestamp
- - message timestamppublic XByteBuffer getMessage()
ChannelMessage
getMessage
in interface ChannelMessage
public void setMessage(XByteBuffer message)
ChannelMessage
setMessage
in interface ChannelMessage
message
- The message to send.public long getTimestamp()
ChannelMessage
getTimestamp
in interface ChannelMessage
public void setTimestamp(long timestamp)
ChannelMessage
setTimestamp
in interface ChannelMessage
timestamp
- The timestamp to sendpublic byte[] getUniqueId()
ChannelMessage
getUniqueId
in interface ChannelMessage
public void setUniqueId(byte[] uniqueId)
uniqueId
- The uniqueId to send.public int getOptions()
ChannelMessage
getOptions
in interface ChannelMessage
Channel.send(Member[], Serializable, int)
,
ChannelInterceptor.getOptionFlag()
public void setOptions(int options)
setOptions
in interface ChannelMessage
options
- the message optionsChannelMessage.getOptions()
public Member getAddress()
getAddress
in interface ChannelMessage
public void setAddress(Member address)
setAddress
in interface ChannelMessage
address
- Memberpublic void generateUUID()
public int getDataPackageLength()
public byte[] getDataPackage()
public byte[] getDataPackage(byte[] data, int offset)
public static ChannelData getDataFromPackage(XByteBuffer xbuf)
xbuf
- byte[]public static ChannelData getDataFromPackage(byte[] b)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- Objectpublic java.lang.Object clone()
clone
in interface ChannelMessage
clone
in class java.lang.Object
public java.lang.Object deepclone()
deepclone
in interface ChannelMessage
public static boolean sendAckSync(int options)
options
- int - the options for the messageChannel.SEND_OPTIONS_USE_ACK
,
Channel.SEND_OPTIONS_SYNCHRONIZED_ACK
public static boolean sendAckAsync(int options)
options
- int - the options for the messageChannel.SEND_OPTIONS_USE_ACK
,
Channel.SEND_OPTIONS_SYNCHRONIZED_ACK
public java.lang.String toString()
toString
in class java.lang.Object
public static java.lang.String bToS(byte[] data)
Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.