|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface MessageView
Represents a view into a message.
From SMA's perspective, a message is just an object with a specific encoding e.g. a byte buffer, a hash table, an STO Container etc. A message view is an in-memory wrapper around a message that provides a specific view into the message contents. This interface defines the base class for all message views.
There are two views defined by SMA - the 'raw' view and the 'map' view.
The raw view (defined by this interface) exposes the message as an object
of a specific encoding type. No additional visibility is available with
the raw view. The map view (defined by MapMessageView
) enables a
user, in addition to seeing the raw message, to view the message as a map
i.e. a set of named fields.
Each message transported through SMA needs to be associated with a specific view. The user instantiates a view around a message and then hands the view over to one of SMAs send methods for delivery. The SMA send side machinery transports the underlying message as well as enough of information to reconsititute the send side message view on the receive side.
The SMA send and receive side machinery implement functionality conditional on the message view supplied. Some functionality requires the 'map' message view e.g. dynamic message key resolution. Functionality dependent on a specific message view will not be available for messages instantiated with message views not derived from the required message view.
Message views are instantiated by message view factories. View factories are
configured with SMA (served by MessageViewFactoryRegistry
). Each
view factory has a system wide unique id. Each instantiated view is uniquely
associated with one and only one factory. It is the id of the factory that
a view is associated that is transported by SMA along with the message. On the
receive side, the transported id is used to locate the appropriate factory
that is invoked to reconstitute the view around the message.
Field Summary | |
---|---|
static int |
ENCODING_TYPE_CUSTOM
Identifies the user custom encoding type |
static int |
ENCODING_TYPE_JSON
Identifies the 'JSON' message encoding |
static int |
ENCODING_TYPE_PROTOBUF
Identifies the 'Protocol Buffer' message encoding |
static int |
ENCODING_TYPE_XBUF
Identifies the 'X Buffer' message encoding |
static int |
NEXT_FREE_ENCODING_TYPE
Identifies the next free encoding type |
Method Summary | |
---|---|
void |
acquire()
Increase a message view's ownership count. |
MessageView |
deserializeFromByteArray(byte[] serializedMessage)
Deserialize a view's backing message from a byte array. |
MessageView |
deserializeFromByteBuffer(ByteBuffer serializedMessage)
Deserialize a view's backing message from a byte buffer. |
MessageView |
deserializeFromPacket(PktPacket serializedMessage)
Deserialize a view's backing message from a packet. |
int |
dispose()
Dispose a message view. |
long |
getCreateTs()
Get a message's create timestamp. |
Object |
getMessage()
Get a view's backing message. |
String |
getMessageBus()
Get the message bus name. |
com.neeve.raw.RawString |
getMessageBusAsRaw()
Get the message bus in RawString form. |
String |
getMessageChannel()
Get the message channel name. |
com.neeve.raw.RawString |
getMessageChannelAsRaw()
Get the message channel in RawString form. |
int |
getMessageEncodingType()
Get the message's encoding type. |
int |
getMessageFlow()
Get the message flow. |
String |
getMessageKey()
Get the message key. |
com.neeve.raw.RawString |
getMessageKeyAsRaw()
Get the message key. |
int |
getMessageSender()
Get the message sender. |
long |
getMessageSequenceNumber()
Get the message sequence number. |
long |
getOriginTs()
Get a message's origin timestamp. |
long |
getOutTs()
Get a message's out timestamp. |
int |
getOwnershipCount()
Get a message view's ownership count. |
long |
getPostDeserializeTs()
Get a message's post-deserialize timestamp. |
long |
getPostProcessingTs()
Get a message's post-processing timestamp. |
long |
getPostSerializeTs()
Get a message's post-serialize timestamp. |
long |
getPostWireTs()
Get a message's post-wire timestamp. |
long |
getPreDeserializeTs()
Get a message's pre-deserialize timestamp. |
long |
getPreProcessingTs()
Get a message's pre-processing timestamp. |
long |
getPreSerializeTs()
Get a message's pre-serialize timestamp. |
long |
getPreWireTs()
Get a message's pre-wire timestamp. |
long |
getReceiveTs()
Get a message's receive timestamp. |
long |
getSendTs()
Get a message's send timestamp. |
Object |
getTag(int id)
Get a message view tag. |
short |
getType()
Get the view type. |
short |
getVfid()
Get the view factory identifier. |
boolean |
isPossibleDuplicate()
Get whether a message is a possible duplicate.. |
byte[] |
serializeToByteArray()
Serialize a view's backing message to a byte array. |
ByteBuffer |
serializeToByteBuffer()
Serialize a view's backing message to a byte buffer. |
PktPacket |
serializeToPacket()
Serialize a view's backing message to a packet. |
MessageView |
setCreateTs(long ts)
Set a message's create timestamp. |
MessageView |
setMessageBus(String name)
Set the message bus name. |
MessageView |
setMessageBusAsRaw(com.neeve.raw.RawString bus)
Set the message bus. |
MessageView |
setMessageChannel(String name)
Set the message channel name. |
MessageView |
setMessageChannelAsRaw(com.neeve.raw.RawString channel)
Set the message channel. |
MessageView |
setMessageFlow(int flow)
Set the message flow. |
MessageView |
setMessageKey(String key)
Set the message key. |
MessageView |
setMessageKeyAsRaw(com.neeve.raw.RawString key)
Set the message key. |
MessageView |
setMessageSender(int sender)
Set the message sender. |
MessageView |
setMessageSequenceNumber(long sno)
Set the message sequence number. |
MessageView |
setOriginTs(long ts)
Set a message's origin timestamp. |
MessageView |
setOutTs(long ts)
Set a message's out timestamp. |
MessageView |
setPossibleDuplicate()
Set a message as a possible duplicate. |
MessageView |
setPostDeserializeTs(long ts)
Set a message's post-deserialize timestamp. |
MessageView |
setPostProcessingTs(long ts)
Set a message's post-processing timestamp. |
MessageView |
setPostSerializeTs(long ts)
Set a message's post-serialize timestamp. |
MessageView |
setPostWireTs(long ts)
Set a message's post-wire timestamp. |
MessageView |
setPreDeserializeTs(long ts)
Set a message's pre-deserialize timestamp. |
MessageView |
setPreProcessingTs(long ts)
Set a message's pre-processing timestamp. |
MessageView |
setPreSerializeTs(long ts)
Set a message's pre-serialize timestamp. |
MessageView |
setPreWireTs(long ts)
Set a message's pre-wire timestamp. |
MessageView |
setReceiveTs(long ts)
Set a message's receive timestamp. |
MessageView |
setSendTs(long ts)
Set a message's send timestamp. |
void |
setTag(int id,
Object tag)
Set a message view tag. |
void |
sync()
Ensure a view's backing message is prepared and ready for transport |
Methods inherited from interface com.neeve.util.UtlReferenceTracker.HasReferenceTracker |
---|
referenceTracker |
Field Detail |
---|
static final int ENCODING_TYPE_CUSTOM
static final int ENCODING_TYPE_XBUF
static final int ENCODING_TYPE_PROTOBUF
static final int ENCODING_TYPE_JSON
static final int NEXT_FREE_ENCODING_TYPE
Method Detail |
---|
void setTag(int id, Object tag)
getTag(int)
A message view tag is an opaque object that can be tagged to a message
view object. Each tag is uniquely identified in the system via a numeric
value View tag ids reserved for internal use by the X Platform are
defined in MessageViewTags
.
Object getTag(int id)
setTag(int, java.lang.Object)
short getVfid()
This method returns the system wide unique identifier of the view factory that instantiated this message view.
short getType()
A message view type uniquely identifies a message within its factory.
int getMessageEncodingType()
This method returns a message's encoding type.
MessageView setMessageBus(String name)
name
- The message bus name to set.
String getMessageBus()
This method returns the bus associated with a message.
MessageView setMessageBusAsRaw(com.neeve.raw.RawString bus)
bus
- The message bus to set.
com.neeve.raw.RawString getMessageBusAsRaw()
RawString
form.
This method returns the bus associated with a message.
MessageView setMessageChannel(String name)
name
- The message channel name to set.
String getMessageChannel()
This method returns the channel associated with a message.
MessageView setMessageChannelAsRaw(com.neeve.raw.RawString channel)
channel
- The message channel to set.
com.neeve.raw.RawString getMessageChannelAsRaw()
RawString
form.
This method returns the channel associated with a message.
MessageView setMessageKey(String key)
key
- The message key to set.
String getMessageKey()
This method returns the key associated with a message.
MessageView setMessageKeyAsRaw(com.neeve.raw.RawString key)
key
- The message key to set.
com.neeve.raw.RawString getMessageKeyAsRaw()
This method returns the key associated with a message.
MessageView setMessageSender(int sender)
sender
- The message sender to set
int getMessageSender()
This method returns the system-wide unique sender id. Sequence numbers
returned by getMessageSequenceNumber()
are scoped by sender.
MessageView setMessageFlow(int flow)
flow
- The message flow to set.
int getMessageFlow()
This method returns the system-wide unique flow id. Flows define the order in which messages need to be processed.
MessageView setMessageSequenceNumber(long sno)
sno
- The sequence number to set.
long getMessageSequenceNumber()
This method returns the sender scoped message sequence number.
MessageView setPossibleDuplicate()
boolean isPossibleDuplicate()
MessageView setOriginTs(long ts)
ts
- The timestamp to set.
long getOriginTs()
This timestamp, in microseconds, specifies the time at which the first message in this message's flow originated.
MessageView setCreateTs(long ts)
ts
- The timestamp to set.
long getCreateTs()
This timestamp, in microseconds, specifies the time at which the message was created.
MessageView setSendTs(long ts)
ts
- The timestamp to set.
long getSendTs()
This timestamp, in microseconds, specifies the time at which the message was sent by the application.
MessageView setOutTs(long ts)
ts
- The timestamp to set.
long getOutTs()
This timestamp is the same timestamp as the 'send' timestamp but in milliseconds.
MessageView setPreSerializeTs(long ts)
ts
- The timestamp to set.
long getPreSerializeTs()
This timestamp, in microseconds, specifies the time just before a message was serialized for transport.
MessageView setPostSerializeTs(long ts)
ts
- The timestamp to set.
long getPostSerializeTs()
This timestamp, in microseconds, specifies the time just after a message was serialized for transport.
MessageView setPreWireTs(long ts)
ts
- The timestamp to set.
This timestamp, in microseconds, specifies the time just before a message was sent on the network (the accuracy of this depends on how close to the wire the SMA binding used can timestamp the message)
long getPreWireTs()
The returned timestamp is in microseconds.
MessageView setPostWireTs(long ts)
ts
- The timestamp to set.
long getPostWireTs()
This timestamp, in microseconds, specifies the time just after a message was received from the network (the accuracy of this depends on how close to the wire the SMA binding used can timestamp the message)
MessageView setPreDeserializeTs(long ts)
ts
- The timestamp to set.
long getPreDeserializeTs()
This timestamp, in microseconds, specifies the time just before a message was de-serialized after transport.
MessageView setPostDeserializeTs(long ts)
ts
- The timestamp to set.
long getPostDeserializeTs()
This timestamp, in microseconds, specifies the time just after a message was de-serialized after transport.
MessageView setReceiveTs(long ts)
ts
- The timestamp to set.
long getReceiveTs()
This timestamp, in microseconds, specifies the time just before a message was received by X's application dispatch machinery. It is the same as the pre-processing timestamp if the message is not being redelivered to the application by the in-process X runtime.
MessageView setPreProcessingTs(long ts)
ts
- The timestamp to set.
long getPreProcessingTs()
This timestamp, in milliseconds, specifies the time just before a message was dispatched to the application for processing.
MessageView setPostProcessingTs(long ts)
ts
- The timestamp to set.
long getPostProcessingTs()
This timestamp, in milliseconds, specifies the time just after a message processing handler completes.
Object getMessage()
This method returns the actual message wrapped by the view. It is the message that is transported
void sync()
byte[] serializeToByteArray()
ByteBuffer serializeToByteBuffer()
PktPacket serializeToPacket()
MessageView deserializeFromByteArray(byte[] serializedMessage)
serializedMessage
- The view's backing message serialized as a byte array.MessageView deserializeFromByteBuffer(ByteBuffer serializedMessage)
serializedMessage
- The view's backing message serialized as a byte buffer.MessageView deserializeFromPacket(PktPacket serializedMessage)
serializedMessage
- The view's backing message serialized as a packet.void acquire()
This method increments a message view's ownership count. View ownership
is used in conjunction with managing message view pools. If a view is
tagged to an object pool, the packet is released back to the pool
by dispose()
when the ownership count reduces to 0. If not
tagged to a pool, change of ownership count has no side effects.
A packet's ownership count starts at 1.
int getOwnershipCount()
int dispose()
This method should be invoked by the user when done with a message view. It decrements the view's ownership count and releases it to its object pool if one is tagged to it and this method cause the ownership count to reduce to zero. If not tagged to a pool, ownership change methods have no side effects aside from just updating the ownership counter.
Once disposed, all references to the disposed view should be discarded.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |