|
|||||||||
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 |
deserializeFromJson(String serializedMessage)
Deserialize a view's backing message from a json string |
MessageView |
deserializeFromPacket(PktPacket serializedMessage)
Deserialize a view's backing message from a packet. |
int |
dispose()
Dispose a message view. |
long |
getAppSendBeginTs()
Get's the time at which the application considers send for a message to start. |
long |
getAppSendDoneTs()
Get's the time at which the application considers send for a message to be complete. |
long |
getCreateTs()
Get a message's create timestamp. |
long |
getEnqueueTs()
Get a message's enqueue timestamp in milliseconds |
long |
getEnqueueTsMicros()
Get a message's enqueue timestamp This timestamp, in microseconds, specifies the time just before a message was enqueued on an application's input queue. |
Object |
getMessage()
Get a view's backing message. |
String |
getMessageBus()
Get the message bus name. |
XString |
getMessageBusAsRaw()
Get the message bus in XString form. |
String |
getMessageChannel()
Get the message channel name. |
XString |
getMessageChannelAsRaw()
Get the message channel in XString form. |
int |
getMessageEncodingType()
Get the message's encoding type. |
int |
getMessageFlow()
Get the message flow. |
String |
getMessageKey()
Get the message key. |
XString |
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. |
long |
getOutTsMicros()
Get a message's out timestamp in microseconds since the epoch. |
int |
getOwnershipCount()
Get a message view's ownership count. |
long |
getPostDeserializeTs()
Get a message's post-deserialize timestamp. |
long |
getPostProcessingTs()
Deprecated. use getPostProcessingTsMicros() instead. |
long |
getPostProcessingTsMicros()
Get a message's post-processing timestamp. |
long |
getPostSerializeTs()
Get a message's post-serialize timestamp. |
long |
getPostWireSendTs()
Get a message's post-wire 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 |
getPreProcessingTsMicros()
Get a message's pre-processing timestamp in microseconds. |
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 |
getSendStartTs()
Get a message's send 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. |
com.neeve.io.IOBuffer |
serializeToIOBuffer(boolean useNative)
Serializes the MessageView to an IOBuffer. |
String |
serializeToJson()
Serialize a view's backing message to JSON. |
PktPacket |
serializeToPacket()
Serialize a view's backing message to a packet. |
MessageView |
setAppSendBeginTs(long ts)
Time at which the application considers send for a message to start. |
MessageView |
setAppSendDoneTs(long ts)
Set's the time at which the application considers send for a message to be complete. |
MessageView |
setCreateTs(long ts)
Set a message's create timestamp. |
MessageView |
setEnqueueTsMicros(long ts)
Sets a message's enqueue timestamp This timestamp, in microseconds, specifies the time just before a message was enqueued on an application's input queue. |
MessageView |
setMessageBus(String name)
Set the message bus name. |
MessageView |
setMessageBusAsRaw(XString bus)
Set the message bus. |
MessageView |
setMessageChannel(String name)
Set the message channel name. |
MessageView |
setMessageChannelAsRaw(XString channel)
Set the message channel. |
MessageView |
setMessageFlow(int flow)
Set the message flow. |
MessageView |
setMessageKey(String key)
Set the message key. |
MessageView |
setMessageKeyAsRaw(XString 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)
Deprecated. Use setOutTsMicros(long) instead |
MessageView |
setOutTsMicros(long ts)
Set a message's out timestamp in microseconds since the epoch. |
MessageView |
setPossibleDuplicate()
Set a message as a possible duplicate. |
MessageView |
setPostDeserializeTs(long ts)
Set a message's post-deserialize timestamp. |
MessageView |
setPostProcessingTs(long ts)
Deprecated. use setPostProcessingTsMicros(long) instead. |
MessageView |
setPostProcessingTsMicros(long ts)
Set a message's post-processing timestamp. |
MessageView |
setPostSerializeTs(long ts)
Set a message's post-serialize timestamp. |
MessageView |
setPostWireSendTs(long ts)
Set a message's post-wire send 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)
Deprecated. To prevent loss of timestamp precision use setPreProcessingTsMicros(long) instead. |
MessageView |
setPreProcessingTsMicros(long ts)
Set a message's pre-processing timestamp in microseconds. |
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 |
setSendStartTs(long ts)
Set a message's send 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(XString bus)
bus
- The message bus to set.
XString getMessageBusAsRaw()
XString
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(XString channel)
channel
- The message channel to set.
XString getMessageChannelAsRaw()
XString
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(XString key)
key
- The message key to set.
XString 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 setAppSendBeginTs(long ts)
ts
- The application's send start timestamp.
long getAppSendBeginTs()
This timestamp, in microseconds, specifies the time at which the send started from from the application's view point. This timestamp is the same as outTs unless an application explicitly sets it to an earlier value.
MessageView setAppSendDoneTs(long ts)
long getAppSendDoneTs()
This timestamp, in microseconds, specifies the time at which
the send completes from an application's perspective. If the message is sent
in the background this value can be lower even the getSendStartTs()
ts
- The application's send start timestamp.
MessageView setSendTs(long ts)
ts
- The timestamp to set.
long getSendTs()
This timestamp, in microseconds, specifies the time at which the message was offered to the bus for begin the send.
MessageView setSendStartTs(long ts)
ts
- The timestamp to set.
long getSendStartTs()
This timestamp, in microseconds, specifies the time at which the message was offered to the bus for send.
@Deprecated MessageView setOutTs(long ts)
setOutTsMicros(long)
instead
ts
- The timestamp to set.
long getOutTs()
This timestamp is the same timestamp as the 'send' timestamp but in milliseconds.
MessageView setOutTsMicros(long ts)
It is expected that this field will be set via a value obtained from
UtlTime#nowSinceEpoch()
ts
- The timestamp to set.
UtlTime.nowSinceEpoch()
long getOutTsMicros()
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)
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)
ts
- The timestamp to set.
long getPreWireTs()
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).
The returned timestamp is in microseconds.
MessageView setPostWireSendTs(long ts)
ts
- The timestamp to set.
long getPostWireSendTs()
This timestamp, in microseconds, specifies the time just
after the bus provider specific network send call returns.
Comparing this timestamp to getPreWireTs()
determines
the time spent in the bus provider's send call.
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.
long getEnqueueTs()
getEnqueueTsMicros()
MessageView setEnqueueTsMicros(long ts)
This timestamp, in microseconds, specifies the time just before a message was enqueued on an application's input queue. This timestamp can be compared with
ts
- the enqueue time in microseconds.long getEnqueueTsMicros()
This timestamp, in microseconds, specifies the time just before a message was enqueued on an application's input queue. This timestamp can be compared with
@Deprecated MessageView setPreProcessingTs(long ts)
setPreProcessingTsMicros(long)
instead.
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 setPreProcessingTsMicros(long ts)
It is expected that this field will be set via a value obtained from
UtlTime#nowSinceEpoch()
ts
- The timestamp to set.
UtlTime.nowSinceEpoch()
long getPreProcessingTsMicros()
It is expected that this field will be set via a value obtained from
UtlTime#nowSinceEpoch()
@Deprecated MessageView setPostProcessingTs(long ts)
setPostProcessingTsMicros(long)
instead.
ts
- The timestamp to set.
@Deprecated long getPostProcessingTs()
getPostProcessingTsMicros()
instead.
This timestamp, in milliseconds, specifies the time just after a message processing handler completes.
MessageView setPostProcessingTsMicros(long ts)
ts
- The timestamp to set.
long getPostProcessingTsMicros()
This timestamp, in microseconds, 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()
com.neeve.io.IOBuffer serializeToIOBuffer(boolean useNative)
MessageView
to an IOBuffer.
Ownership of the returned IOBuffer is given to the caller which should dispose of it when done.
The buffer backing the IOBuffer should be flipped (ready for read) upon return.
useNative
- Whether the returned buffer should be native.
MessageView
serialized to an IOBuffer.PktPacket serializeToPacket()
String serializeToJson()
Serializing/deserializing a message to/from JSON is an optional operation
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.MessageView deserializeFromJson(String serializedMessage)
serializedMessage
- The view's backing message serialized as a json string.
Serializing/deserializing a message to/from JSON is an optional operation
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 |