public abstract class Message extends Object
Message objects are used to represent all outputs from the API including
subscription data, response, administrative and status messages. Message
objects are obtained from a MessageIterator. A message always has
a message type and may optionally contain the following
* topicName - valid for Subscription data messages
* service - The service from which this message was received from
* correlationId - one or more correlationIds if this message was
delivered for a pending request or a subscription
A Message object is a handle to a single underlying protocol message. The Message contents are represented as an Element and some convenient shortcuts are supplied to the Element accessors.
| Modifier and Type | Class and Description |
|---|---|
static class |
Message.Fragment
A message could be split into more than one fragments to reduce
each message size.
|
static class |
Message.Recap
Some subscription data messages (messages which originate from events
with event type
Event.EventType.SUBSCRIPTION_DATA)
are recaps, which summarize the overall state of the data associated
with a subscription. |
| Modifier and Type | Method and Description |
|---|---|
abstract Element |
asElement()
Returns the contents of this Message as a read-only
Element. |
abstract CorrelationID |
correlationID()
Return the correlationId associated with this message.
|
abstract CorrelationID |
correlationID(int index)
Return the correlationId associated with this message at the specified
index
|
abstract CorrelationID |
correlationIDAt(int index)
Deprecated.
As of 3.2.1, use
correlationID(int) |
abstract Message.Fragment |
fragmentType()
Return the fragment type.
|
abstract Element |
getElement(Name name)
Return the element of this message having the specified name.
|
abstract Element |
getElement(String name)
Return the element of this message having the specified name.
|
abstract boolean |
getElementAsBool(Name name)
Return the value of the element having specified name as a boolean value
|
abstract boolean |
getElementAsBool(String name)
Return the value of the element having specified name as a boolean value
|
abstract byte[] |
getElementAsBytes(Name name)
Return the value of the element having specified name as a byte array
|
abstract byte[] |
getElementAsBytes(String name)
Return the value of the element having specified name as a byte array
|
abstract char |
getElementAsChar(Name name)
Return the value of the element having specified name as a char value
|
abstract char |
getElementAsChar(String name)
Return the value of the element having specified name as a char value
|
abstract Datetime |
getElementAsDate(Name name)
Return the value of the element having specified name as a Date value
|
abstract Datetime |
getElementAsDate(String name)
Return the value of the element having specified name as a Date value
|
abstract Datetime |
getElementAsDatetime(Name name)
Return the value of the element having specified name as a Datetime
value
|
abstract Datetime |
getElementAsDatetime(String name)
Return the value of the element having specified name as a Datetime
value
|
abstract float |
getElementAsFloat32(Name name)
Return the value of the element having specified name as a float value
|
abstract float |
getElementAsFloat32(String name)
Return the value of the element having specified name as a float value
|
abstract double |
getElementAsFloat64(Name name)
Return the value of the element having specified name as a double value
|
abstract double |
getElementAsFloat64(String name)
Return the value of the element having specified name as a double value
|
abstract int |
getElementAsInt32(Name name)
Return the value of the element having specified name as a int value
|
abstract int |
getElementAsInt32(String name)
Return the value of the element having specified name as a int value
|
abstract long |
getElementAsInt64(Name name)
Return the value of the element having specified name as a long value
|
abstract long |
getElementAsInt64(String name)
Return the value of the element having specified name as a long value
|
abstract Name |
getElementAsName(Name name)
Return the value of the element having specified name as a Constant value
|
abstract Name |
getElementAsName(String name)
Return the value of the element having specified name as a Constant value
|
abstract String |
getElementAsString(Name name)
Return the value of the element having specified name as a String value
|
abstract String |
getElementAsString(String name)
Return the value of the element having specified name as a String value
|
abstract Datetime |
getElementAsTime(Name name)
Return the value of the element having specified name as a Time value
|
abstract Datetime |
getElementAsTime(String name)
Return the value of the element having specified name as a Time value
|
abstract boolean |
hasElement(Name name)
Return true if this message has the element having the specified name
false otherwise
|
abstract boolean |
hasElement(Name name,
boolean excludeNullElements)
Return true if this message has the element having the specified name
false otherwise
|
abstract boolean |
hasElement(String name)
Return true if this message has the element having the specified name
false otherwise
|
abstract boolean |
hasElement(String name,
boolean excludeNullElements)
Return true if this message has the element having the specified name
false otherwise
|
abstract boolean |
isValid() |
abstract Name |
messageType()
Return the Name constant representing the type of the message
|
abstract int |
numCorrelationIds()
Return the number of correlation ids associated with this message.
|
abstract int |
numElements()
Return the number of elements contained by this message
|
abstract void |
print(OutputStream output)
Prints the contents of this message to OutputStream.
|
abstract void |
print(Writer writer)
Prints the contents of this message to Writer.
|
abstract Message.Recap |
recapType()
Return the recap type.
|
abstract Service |
service()
Return the Service associated with this message.
|
abstract long |
timeReceivedMillis()
Return the time when the message was received by the SDK and '0'
if there is no timestamp associated with this Message.
|
abstract String |
topicName()
Return the topic string associated with this message.
|
abstract String |
toString()
Returns the contents of this message as a String
|
public abstract String topicName()
public abstract Service service()
public abstract Name messageType()
public abstract Message.Fragment fragmentType()
public abstract Message.Recap recapType()
Message.Recap to indicate whether this message is a solicited
recap, an unsolicited recap, or neither.public abstract CorrelationID correlationID()
This is same as calling correlationID(0).
If there is more than one correlationId associated with this message
return the first correlationId. If there are no correlationIds available
for this message return null
public abstract CorrelationID correlationIDAt(int index)
correlationID(int)public abstract CorrelationID correlationID(int index)
Normally each message is associated with only one correlationId. See
"allowMultipeCorrelatorsPerMsg" option in SessionOptions for
more information on when multiple correlators can be returned per
message
IndexOutOfBoundsException - if
index >= numCorrelationIds()public abstract int numCorrelationIds()
Note: A Message will have exactly one CorrelationId unless "allowMultipleCorrelatorsPerMsg" option was enabled for the Session this Message came from. When allowMultipleCorrelatorsPerMsg is disabled (the default) and more than one active subscription would result in the same Message the Message is delivered multiple times (without making a physical copy). Each Message is accompanied by a single CorrelationId. When "allowMultipleCorrelatorsPerMsg" is enabled and more than one active subscription would result in the same Message the Message is delivered once with a list of corresponding CorrelationId values.
SessionOptionspublic abstract long timeReceivedMillis()
System.currentTimeMillis() is used to get the current
time. Note that by default the subscription data messages are not
timestamped (but all the other messages are). To enable recording
receive time for all messages set
SessionOptions.setRecordSubscriptionDataReceiveTimes(boolean).public abstract Element asElement()
Element.public abstract int numElements()
Same as calling asElement().Element.numElements()
public abstract boolean isValid()
public abstract boolean hasElement(Name name)
Same as calling asElement().Element.hasElement(Name)
public abstract boolean hasElement(Name name, boolean excludeNullElements)
Same as calling
asElement().Element.hasElement(Name, boolean)
public abstract boolean hasElement(String name)
Same as calling asElement().Element.hasElement(String)
public abstract boolean hasElement(String name, boolean excludeNullElements)
Same as calling
asElement().Element.hasElement(String, boolean)
public abstract Element getElement(Name name)
Same as calling asElement().Element.getElement(Name)
NotFoundException - if this message does not contain an element
having the specified namepublic abstract Element getElement(String name)
Same as calling asElement().Element.getElement(String)
NotFoundException - if this message does not contain an element
having the specified namepublic abstract boolean getElementAsBool(Name name)
Same as calling asElement().Element.getElementAsBool(Name)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a boolean valuepublic abstract boolean getElementAsBool(String name)
Same as calling asElement().Element.getElementAsBool(String)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a boolean valuepublic abstract byte[] getElementAsBytes(Name name)
Same as calling asElement().Element.getElementAsBytes(Name)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a byte arraypublic abstract byte[] getElementAsBytes(String name)
Same as calling asElement().Element.getElementAsBytes(String)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a byte arraypublic abstract char getElementAsChar(Name name)
Same as calling asElement().Element.getElementAsChar(Name)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a char valuepublic abstract char getElementAsChar(String name)
Same as calling asElement().Element.getElementAsChar(String)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a char valuepublic abstract int getElementAsInt32(Name name)
Same as calling asElement().Element.getElementAsInt32(Name)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a int valuepublic abstract int getElementAsInt32(String name)
Same as calling asElement().Element.getElementAsInt32(String)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a int valuepublic abstract long getElementAsInt64(Name name)
Same as calling asElement().Element.getElementAsInt64(Name)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a long valuepublic abstract long getElementAsInt64(String name)
Same as calling asElement().Element.getElementAsInt64(String)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a long valuepublic abstract double getElementAsFloat64(Name name)
Same as calling asElement().Element.getElementAsFloat64(Name)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a double valuepublic abstract double getElementAsFloat64(String name)
Same as calling asElement().Element.getElementAsFloat64(String)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a double valuepublic abstract float getElementAsFloat32(Name name)
Same as calling asElement().Element.getElementAsFloat32(Name)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a float valuepublic abstract float getElementAsFloat32(String name)
Same as calling asElement().Element.getElementAsFloat32(String)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a float valuepublic abstract String getElementAsString(Name name)
Same as calling asElement().Element.getElementAsString(Name)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a String valuepublic abstract String getElementAsString(String name)
Same as calling asElement().Element.getElementAsString(String)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a String valuepublic abstract Datetime getElementAsDatetime(Name name)
Same as calling asElement().Element.getElementAsDatetime(Name)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a Datetime valuepublic abstract Datetime getElementAsDatetime(String name)
Same as calling asElement().Element.getElementAsDatetime(String)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a Datetime valuepublic abstract Datetime getElementAsDate(Name name)
Same as calling asElement().Element.getElementAsDate(Name)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a Date valuepublic abstract Datetime getElementAsDate(String name)
Same as calling asElement().Element.getElementAsDate(String)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a Date valuepublic abstract Datetime getElementAsTime(Name name)
Same as calling asElement().Element.getElementAsTime(Name)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a Time valuepublic abstract Datetime getElementAsTime(String name)
Same as calling asElement().Element.getElementAsTime(String)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a Time valuepublic abstract Name getElementAsName(Name name)
Same as calling asElement().Element.getElementAsName(Name)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a Time valuepublic abstract Name getElementAsName(String name)
Same as calling asElement().Element.getElementAsName(String)
NotFoundException - if this message does not contain an element
having the specified nameInvalidConversionException - if the value is not convertible to
a Time valuepublic abstract String toString()
public abstract void print(OutputStream output) throws IOException
IOExceptionpublic abstract void print(Writer writer) throws IOException
IOExceptionCopyright © 2019 Bloomberg L.P.. All rights reserved.