Class Message
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
A message could be split into more than one fragments to reduce each message size.static enum
Some subscription data messages (messages which originate from events with event typeEvent.EventType.SUBSCRIPTION_DATA
) are recaps, which summarize the overall state of the data associated with a subscription. -
Method Summary
Modifier and TypeMethodDescriptionabstract Element
Returns the contents of this Message as a read-onlyElement
.abstract CorrelationID
Return the correlationId associated with this message.abstract CorrelationID
correlationID
(int index) Return the correlationId associated with this message at the specified indexabstract CorrelationID
correlationIDAt
(int index) Deprecated.abstract Message.Fragment
Return the fragment type.abstract Element
getElement
(Name name) Return the element of this message having the specified name.abstract Element
getElement
(String name) Deprecated.Use {getElement(Name)
instead.abstract boolean
getElementAsBool
(Name name) Return the value of the element having specified name as a boolean valueabstract boolean
getElementAsBool
(String name) Deprecated.Use {getElementAsBool(Name)
instead.abstract byte[]
getElementAsBytes
(Name name) Return the value of the element having specified name as a byte arrayabstract byte[]
getElementAsBytes
(String name) Deprecated.Use {getElementAsBytes(Name)
instead.abstract char
getElementAsChar
(Name name) Return the value of the element having specified name as a char valueabstract char
getElementAsChar
(String name) Deprecated.Use {getElementAsChar(Name)
instead.abstract Datetime
getElementAsDate
(Name name) Return the value of the element having specified name as a Date valueabstract Datetime
getElementAsDate
(String name) Deprecated.Use {getElementAsDate(Name)
instead.abstract Datetime
getElementAsDatetime
(Name name) Return the value of the element having specified name as a Datetime valueabstract Datetime
getElementAsDatetime
(String name) Deprecated.Use {getElementAsDatetime(Name)
instead.abstract float
getElementAsFloat32
(Name name) Return the value of the element having specified name as a float valueabstract float
getElementAsFloat32
(String name) Deprecated.Use {getElementAsFloat32(Name)
instead.abstract double
getElementAsFloat64
(Name name) Return the value of the element having specified name as a double valueabstract double
getElementAsFloat64
(String name) Deprecated.Use {getElementAsFloat64(Name)
instead.abstract int
getElementAsInt32
(Name name) Return the value of the element having specified name as a int valueabstract int
getElementAsInt32
(String name) Deprecated.Use {getElementAsInt32(Name)
instead.abstract long
getElementAsInt64
(Name name) Return the value of the element having specified name as a long valueabstract long
getElementAsInt64
(String name) Deprecated.Use {getElementAsInt64(Name)
instead.abstract Name
getElementAsName
(Name name) Return the value of the element having specified name as a Constant valueabstract Name
getElementAsName
(String name) Deprecated.Use {getElementAsName(Name)
instead.abstract String
getElementAsString
(Name name) Return the value of the element having specified name as a String valueabstract String
getElementAsString
(String name) Deprecated.Use {getElementAsString(Name)
instead.abstract Datetime
getElementAsTime
(Name name) Return the value of the element having specified name as a Time valueabstract Datetime
getElementAsTime
(String name) Deprecated.Use {getElementAsTime(Name)
instead.abstract String
Returns the request id of the message if one exists, otherwise,null
.abstract boolean
hasElement
(Name name) Return true if this message has the element having the specified name false otherwiseabstract boolean
hasElement
(Name name, boolean excludeNullElements) Return true if this message has the element having the specified name false otherwiseabstract boolean
hasElement
(String name) Deprecated.Use {hasElement(Name)
instead.abstract boolean
hasElement
(String name, boolean excludeNullElements) Deprecated.Use {hasElement(Name, boolean)
instead.abstract boolean
isValid()
abstract Name
Return the Name constant representing the type of the messageabstract int
Return the number of correlation ids associated with this message.abstract int
Return the number of elements contained by this messageabstract void
print
(OutputStream output) Prints the contents of this message to OutputStream.abstract void
Prints the contents of this message to Writer.abstract Message.Recap
Return the recap type.abstract Service
service()
Return the Service associated with this message.abstract long
Return the time when the message was received by the SDK and '0' if there is no timestamp associated with this Message.abstract String
Deprecated.as of 3.15.0 This function has been deprecated because a message's payload can be associated with different correlation ids/subscriptions, and each of these correlation ids may map to different topic strings.abstract String
toString()
Returns the contents of this message as a String
-
Method Details
-
topicName
Deprecated.as of 3.15.0 This function has been deprecated because a message's payload can be associated with different correlation ids/subscriptions, and each of these correlation ids may map to different topic strings.In such scenarios, it will be incorrect to return one out of the topics (for the various correlation ids in the message) as the topic name for the message.
Applications should use correlation ids to map to the subscriptions.
Return the topic string associated with this message. Return an empty string if there is no topic associated with this message. -
service
Return the Service associated with this message. Return null if this method is not associated with a service -
messageType
Return the Name constant representing the type of the message -
fragmentType
Return the fragment type. The return value is a value of enum Fragment to indicate whether it is a fragmented message of a big message and its positions in fragmentation if it is. -
recapType
Return the recap type. The return value is a value ofMessage.Recap
to indicate whether this message is a solicited recap, an unsolicited recap, or neither.- Returns:
- The recap type associated with this message
-
correlationID
Return the correlationId associated with this message.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- Returns:
- correlationId associated with this message if available null otherwise
-
correlationIDAt
Deprecated.As of 3.2.1, usecorrelationID(int)
-
correlationID
Return the correlationId associated with this message at the specified indexNormally 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- Throws:
IndexOutOfBoundsException
- ifindex >=
numCorrelationIds()
-
numCorrelationIds
public abstract int numCorrelationIds()Return the number of correlation ids associated with this message.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.
- See Also:
-
timeReceivedMillis
public 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.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 setSessionOptions.setRecordSubscriptionDataReceiveTimes(boolean)
. -
asElement
Returns the contents of this Message as a read-onlyElement
. -
numElements
public abstract int numElements()Return the number of elements contained by this messageSame as calling
asElement()
.Element.numElements()
-
isValid
public abstract boolean isValid() -
hasElement
Return true if this message has the element having the specified name false otherwiseSame as calling
asElement()
.Element.hasElement(Name)
-
hasElement
Return true if this message has the element having the specified name false otherwiseSame as calling
asElement()
.Element.hasElement(Name, boolean)
-
hasElement
Deprecated.Use {hasElement(Name)
instead.Return true if this message has the element having the specified name false otherwiseSame as calling
asElement()
.Element.hasElement(String)
-
hasElement
Deprecated.Use {hasElement(Name, boolean)
instead.Return true if this message has the element having the specified name false otherwiseSame as calling
asElement()
.Element.hasElement(String, boolean)
-
getElement
Return the element of this message having the specified name.Same as calling
asElement()
.Element.getElement(Name)
- Throws:
NotFoundException
- if this message does not contain an element having the specified name
-
getElement
Deprecated.Use {getElement(Name)
instead.Return the element of this message having the specified name.Same as calling
asElement()
.Element.getElement(String)
- Throws:
NotFoundException
- if this message does not contain an element having the specified name
-
getElementAsBool
Return the value of the element having specified name as a boolean valueSame as calling
asElement()
.Element.getElementAsBool(Name)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a boolean value
-
getElementAsBool
Deprecated.Use {getElementAsBool(Name)
instead.Return the value of the element having specified name as a boolean valueSame as calling
asElement()
.Element.getElementAsBool(String)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a boolean value
-
getElementAsBytes
Return the value of the element having specified name as a byte arraySame as calling
asElement()
.Element.getElementAsBytes(Name)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a byte array
-
getElementAsBytes
Deprecated.Use {getElementAsBytes(Name)
instead.Return the value of the element having specified name as a byte arraySame as calling
asElement()
.Element.getElementAsBytes(String)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a byte array
-
getElementAsChar
Return the value of the element having specified name as a char valueSame as calling
asElement()
.Element.getElementAsChar(Name)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a char value
-
getElementAsChar
Deprecated.Use {getElementAsChar(Name)
instead.Return the value of the element having specified name as a char valueSame as calling
asElement()
.Element.getElementAsChar(String)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a char value
-
getElementAsInt32
Return the value of the element having specified name as a int valueSame as calling
asElement()
.Element.getElementAsInt32(Name)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a int value
-
getElementAsInt32
Deprecated.Use {getElementAsInt32(Name)
instead.Return the value of the element having specified name as a int valueSame as calling
asElement()
.Element.getElementAsInt32(String)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a int value
-
getElementAsInt64
Return the value of the element having specified name as a long valueSame as calling
asElement()
.Element.getElementAsInt64(Name)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a long value
-
getElementAsInt64
Deprecated.Use {getElementAsInt64(Name)
instead.Return the value of the element having specified name as a long valueSame as calling
asElement()
.Element.getElementAsInt64(String)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a long value
-
getElementAsFloat64
Return the value of the element having specified name as a double valueSame as calling
asElement()
.Element.getElementAsFloat64(Name)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a double value
-
getElementAsFloat64
Deprecated.Use {getElementAsFloat64(Name)
instead.Return the value of the element having specified name as a double valueSame as calling
asElement()
.Element.getElementAsFloat64(String)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a double value
-
getElementAsFloat32
Return the value of the element having specified name as a float valueSame as calling
asElement()
.Element.getElementAsFloat32(Name)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a float value
-
getElementAsFloat32
Deprecated.Use {getElementAsFloat32(Name)
instead.Return the value of the element having specified name as a float valueSame as calling
asElement()
.Element.getElementAsFloat32(String)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a float value
-
getElementAsString
Return the value of the element having specified name as a String valueSame as calling
asElement()
.Element.getElementAsString(Name)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a String value
-
getElementAsString
Deprecated.Use {getElementAsString(Name)
instead.Return the value of the element having specified name as a String valueSame as calling
asElement()
.Element.getElementAsString(String)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a String value
-
getElementAsDatetime
Return the value of the element having specified name as a Datetime valueSame as calling
asElement()
.Element.getElementAsDatetime(Name)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a Datetime value
-
getElementAsDatetime
Deprecated.Use {getElementAsDatetime(Name)
instead.Return the value of the element having specified name as a Datetime valueSame as calling
asElement()
.Element.getElementAsDatetime(String)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a Datetime value
-
getElementAsDate
Return the value of the element having specified name as a Date valueSame as calling
asElement()
.Element.getElementAsDate(Name)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a Date value
-
getElementAsDate
Deprecated.Use {getElementAsDate(Name)
instead.Return the value of the element having specified name as a Date valueSame as calling
asElement()
.Element.getElementAsDate(String)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a Date value
-
getElementAsTime
Return the value of the element having specified name as a Time valueSame as calling
asElement()
.Element.getElementAsTime(Name)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a Time value
-
getElementAsTime
Deprecated.Use {getElementAsTime(Name)
instead.Return the value of the element having specified name as a Time valueSame as calling
asElement()
.Element.getElementAsTime(String)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a Time value
-
getElementAsName
Return the value of the element having specified name as a Constant valueSame as calling
asElement()
.Element.getElementAsName(Name)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a Time value
-
getElementAsName
Deprecated.Use {getElementAsName(Name)
instead.Return the value of the element having specified name as a Constant valueSame as calling
asElement()
.Element.getElementAsName(String)
- Throws:
NotFoundException
- if this message does not contain an element having the specified nameInvalidConversionException
- if the value is not convertible to a Time value
-
getRequestId
Returns the request id of the message if one exists, otherwise,null
.When present, the request id can be reported to Bloomberg to troubleshoot the cause of failure messages, or issues with the data contained in the message.
Note that request id is not the same as correlation id and should not be used for correlation purposes.
-
toString
Returns the contents of this message as a String -
print
Prints the contents of this message to OutputStream.- Throws:
IOException
-
print
Prints the contents of this message to Writer.- Throws:
IOException
-
correlationID(int)