public class MessageImpl extends Object implements Message, BytesXMLMessageWrapper
MSGDUMP_BRIEF, MSGDUMP_FULL, SDK_BINARY_METADATA_PORTION, STRUCTURED_MAP_MESSAGE, STRUCTURED_STREAM_MESSAGE, STRUCTURED_TEXT_MESSAGE, UNSTRUCTURED_JMS_BYTES_MESSAGE, UNSTRUCTURED_JMS_OBJECT_MESSAGE, UNSTRUCTURED_JMS_PROPERTIES_MESSAGE, UNSTRUCTURED_MESSAGE, UNSTRUCTURED_XML_MESSAGE| Constructor and Description |
|---|
MessageImpl(BytesXMLMessage message) |
| Modifier and Type | Method and Description |
|---|---|
void |
ackMessage()
Acknowledges the message.
|
void |
clearAttachment()
Deletes the attachment to the message.
|
void |
clearBinaryMetadataBytes(int type)
Clears any existing binary metadata.
|
void |
clearContent()
Clears the message content.
|
void |
clearQueueNameLocation() |
void |
clearTopicNameLocation() |
String |
dump()
Produces a human-readable dump of the message properties and its contents
(can be quite large).
|
String |
dump(int flags)
Produces a human-readable dump of the message properties and its
contents.
|
long |
getAckMessageId() |
String |
getApplicationMessageId()
Gets the application message ID, a string for an application-specific
message identifier.
|
String |
getApplicationMessageType()
Gets the application message type.
|
String |
getAppMessageID() |
String |
getAppMessageType() |
ByteBuffer |
getAttachmentByteBuffer()
Gets a
ByteBuffer containing the message's binary
attachment. |
int |
getAttachmentContentLength()
Gets the length of the attachment.
|
int |
getBinaryMetadataContentLength(int type) |
Collection<Integer> |
getBinaryMetadataTypes() |
byte[] |
getBytes()
Gets a byte array with the message content of the XML part.
|
Long |
getCacheRequestId()
Return the request ID set in the cache request.
|
List<Long> |
getConsumerIdList()
Gets a read-only list of consumer IDs set on this message.
|
int |
getContentLength()
The length of the message content.
|
String |
getCorrelationId()
Gets the correlation ID.
|
Object |
getCorrelationKey()
Gets the correlation key for the message.
|
User_Cos |
getCos()
Gets the Class of Service (CoS) value for this message.
|
boolean |
getDeliverToOne()
Gets whether this message is configured for delivering to one client only.
|
DeliveryMode |
getDeliveryMode()
Gets the delivery mode of the message.
|
Destination |
getDestination()
Gets the destination this message was published to.
|
String |
getDestinationTopicSuffix()
Returns the string, without a leading delimiter, that is found after the
session's default ReplyTo base topic in an incoming message.
|
boolean |
getDiscardIndication()
Returns
true if one or more messages have been discarded
prior to the current message, else false. |
long |
getExpiration()
The UTC time (in milliseconds, from midnight, January 1, 1970 UTC) when the message is supposed to expire.
|
String |
getHTTPContentEncoding()
Gets the HTTP content encoding header value from interaction with an HTTP client.
|
String |
getHTTPContentType()
Gets the HTTP content type header value from interaction with an HTTP client.
|
String |
getMessageId()
Returns the message ID set by JCSMP during send or reception.
|
long |
getMessageIdLong()
Returns the message ID set by JCSMP during send or reception.
|
MessageType |
getMessageType() |
int |
getPriority()
Returns priority value in the range of 0–255, or -1 if it is not set.
|
SDTMap |
getProperties()
Gets the user properties map.
|
int |
getQueueNameLength() |
int |
getQueueNameOffset() |
long |
getReceiveTimestamp()
Gets the receive timestamp (in milliseconds, from midnight, January 1, 1970 UTC).
|
boolean |
getRedelivered()
Indicates if the message has been delivered by the appliance to the API before.
|
Destination |
getReplyTo()
Gets the replyTo destination
|
String |
getReplyToSuffix()
Returns the appended suffix to the session's default ReplyTo base topic
set as part of this message's ReplyTo topic destination.
|
String |
getSenderId()
Returns the Sender's ID.
|
String |
getSenderID() |
Long |
getSenderTimestamp()
Gets the send timestamp (in milliseconds, from midnight, January 1, 1970
UTC).
|
Long |
getSendTimestamp() |
Long |
getSequenceNumber()
Gets the sequence number.
|
byte |
getStructuredMsgType()
Gets the structured message type.
|
long |
getTimeToLive()
The number of milliseconds before the message is discarded or moved to
Dead Message Queue.
|
int |
getTopicNameLength() |
int |
getTopicNameOffset() |
Long |
getTopicSequenceNumber()
Gets the topic sequence number generated by the appliance.
|
boolean |
getTQDiscardIndication() |
byte[] |
getUserData()
When an application sends a message, it can optionally attach
application-specific data along with the message, such as user data.
|
BytesXMLMessage |
getWrappedMessage() |
boolean |
hasAttachment()
Checks whether the message has an attachment.
|
boolean |
hasBinaryMetadata(int type) |
boolean |
hasContent()
Checks whether the message has content.
|
boolean |
hasUserData()
Checks whether a received message includes user data.
|
boolean |
isAckImmediately()
Test if the ACK Immediately message property is set or not.
|
boolean |
isCacheMessage()
Returns
true if this message was part of a cache reply. |
boolean |
isDMQEligible()
The method returns whether the message is eligible to be moved to a Dead Message Queue (DMQ)
upon expiration.
|
boolean |
isElidingEligible()
Checks whether the message is eligible for eliding.
|
boolean |
isReadOnly()
Tests if the message is read only.
|
boolean |
isReplyMessage()
Returns whether the message's reply field is set, indicating that this
message is a reply.
|
boolean |
isStructuredMsg()
Returns whether the message is a structured message.
|
boolean |
isSuspect()
Return
true if this message was part of a cache reply that had the suspect flag set. |
int |
readAttachmentBytes(byte[] byteOutputBuffer)
Reads bytes from an attachment, copying the data to the supplied byte
array.
|
int |
readAttachmentBytes(byte[] byteOutputBuffer,
int length)
Reads
length bytes from an attachment, copying the data to
the supplied byte array. |
int |
readAttachmentBytes(int srcPos,
byte[] byteOutputBuffer,
int destPos,
int length)
Reads
length bytes from an attachment, copying the data to
the supplied byte array. |
int |
readBinaryMetadataBytes(int type,
byte[] byteOutputBuffer) |
int |
readBytes(byte[] value)
Reads a byte array from the message content and copies the data read to
the supplied byte array.
|
int |
readBytes(byte[] value,
int length)
Reads
length bytes from the message content, and copies the
data read to the supplied byte array. |
int |
readContentBytes(byte[] byteOutputBuffer)
Reads from the message content, copying the data to the supplied byte
array.
|
int |
readContentBytes(byte[] byteOutputBuffer,
int length)
Reads
length bytes from the message content, copying the
data to the supplied byte array. |
int |
readContentBytes(int srcPos,
byte[] byteOutputBuffer,
int destPos,
int length)
Reads
length bytes from the message content, copying the
data to the supplied byte array. |
void |
rejectMessage() |
void |
reset()
Resets the message, clearing all fields, preparing it for publishing
again.
|
void |
rewindAttachment()
Resets the read mark for attachment to 0.
|
void |
rewindContent()
Resets the read mark for the message content to 0.
|
void |
setAckImmediately(boolean ackImmediately)
Set the ACK Immediately message property.
|
void |
setApplicationMessageId(String msgId)
Sets the message ID (a string for an application-specific message
identifier).
|
void |
setApplicationMessageType(String appMsgType)
Sets the application message type.
|
void |
setAppMessageID(String msgId) |
void |
setAppMessageType(String appMsgType) |
void |
setAsReplyMessage(boolean isResponse)
Sets the reply field of the message.
|
void |
setCorrelationId(String id)
Sets the correlation ID.
|
void |
setCorrelationKey(Object key)
Sets the correlation key for the message.
|
void |
setCos(User_Cos cosValue)
Sets the Class of Service (CoS) value for this message.
|
void |
setDeliverToOne(boolean deliverToOne)
Configures this message to be delivered to one client only.
|
void |
setDeliveryMode(DeliveryMode mode)
Sets the delivery mode of the message.
|
void |
setDMQEligible(boolean dmqEligible)
Set the message to be eligible to be moved to a Dead Message Queue.
|
void |
setElidingEligible(boolean eliding)
Sets whether the message is eligible for eliding.
|
void |
setExpiration(long expiration)
The UTC time (in milliseconds, from midnight, January 1, 1970 UTC) when the message is supposed to expire.
|
void |
setHTTPContentEncoding(String contentEncoding)
Sets the HTTP content type encoding value for interaction with an HTTP client.
|
void |
setHTTPContentType(String contentType)
Sets the HTTP content type header value for interaction with an HTTP client.
|
void |
setMessageType(MessageType msgType) |
void |
setPriority(int priority)
A message can optionally have priority set.
|
void |
setProperties(SDTMap props)
This method allows users to specify their own user properties to be
carried in the message separate from the payload.
|
void |
setQueueNameLocation(int offset,
int length) |
void |
setReadOnly()
The message can be set as read only.
|
void |
setReplyTo(Destination destination)
Sets the replyTo destination for the message.
|
void |
setReplyToSuffix(String suffix)
Appends a String to the session's default ReplyTo base topic and creates
a ReplyTo Topic Destination.
|
void |
setSenderId(String senderId)
Sets the Sender ID for the message.
|
void |
setSenderID(String senderID) |
void |
setSenderTimestamp(long ts)
Allows the application to set the send timestamp overriding the API's
generated value.
|
void |
setSendTimestamp(long ts) |
void |
setSequenceNumber(long seqNum)
Sets the sequence number.
|
void |
setStructuredMsg(boolean isStructured)
Sets the message as a structured message.
|
void |
setStructuredMsgType(byte value)
Sets the structured message type.
|
void |
setTimeToLive(long ttl)
The number of milliseconds before the message is discarded or moved to a
Dead Message Queue.
|
void |
setTopicNameLocation(int offset,
int length) |
void |
setUserData(byte[] userData)
When an application sends a message, it can optionally attach
application-specific data along with the message as user data.
|
String |
toString() |
int |
writeAttachment(byte[] byteInputBuffer)
Writes a new attachment to the message.
|
int |
writeAttachment(byte[] byteInputBuffer,
int offset,
int length)
Writes a new attachment to the message.
|
int |
writeAttachment(InputStream stream)
Writes a new attachment to the message.
|
int |
writeBinaryMetadataBytes(int type,
byte[] byteInputBuffer) |
int |
writeBinaryMetadataBytes(int type,
byte[] byteInputBuffer,
int offset,
int length) |
void |
writeBytes(byte[] value)
Writes a byte array to the message content of the XML part, appending to existing content
if present.
|
void |
writeBytes(byte[] value,
int offset,
int length)
Writes a partial byte array to the message content of the XML part, appending to existing
content if present.
|
int |
writeNewAttachment(byte[] byteInputBuffer)
Writes a new attachment to the message.
|
int |
writeNewAttachment(byte[] byteInputBuffer,
int offset,
int length)
Writes a new attachment to the message.
|
int |
writeNewAttachment(InputStream stream)
Writes a new attachment to the message.
|
int |
writeNewAttachment(InputStream stream,
int offset,
int length)
Writes a new attachment to the message.
|
public MessageImpl(BytesXMLMessage message)
public BytesXMLMessage getWrappedMessage()
getWrappedMessage in interface BytesXMLMessageWrapperpublic void ackMessage()
XMLMessage
If a JCSMPSession is configured to use
SUPPORTED_MESSAGE_ACK_CLIENT, when a message is successfully received by
an application, the application must call this method to explicitly
acknowledge reception of the message in order to free system resources
associated with an unacknowledged message.
Note: If a JCSMPSession is configured to use
JCSMPProperties.SUPPORTED_MESSAGE_ACK_AUTO (the default behaviour),
the call to this method is ignored and a warning log is generated.
Acknowledged messages are removed from the appliance's message spool.
ackMessage in interface XMLMessagepublic void clearAttachment()
XMLMessageclearAttachment in interface XMLMessagepublic void clearBinaryMetadataBytes(int type)
XMLMessageclearBinaryMetadataBytes in interface XMLMessagetype - Type of binary metadata to clear.public void clearContent()
XMLMessageclearContent in interface XMLMessagepublic void clearQueueNameLocation()
clearQueueNameLocation in interface XMLMessagepublic void clearTopicNameLocation()
clearTopicNameLocation in interface XMLMessagepublic String getAppMessageID()
getAppMessageID in interface XMLMessagepublic String getApplicationMessageId()
XMLMessagegetApplicationMessageId in interface XMLMessagenull if it was not set on send.public String getAppMessageType()
getAppMessageType in interface XMLMessagepublic String getApplicationMessageType()
XMLMessagegetApplicationMessageType in interface XMLMessagepublic int getAttachmentContentLength()
XMLMessagegetAttachmentContentLength in interface XMLMessagepublic ByteBuffer getAttachmentByteBuffer()
XMLMessageByteBuffer containing the message's binary
attachment. The buffer's position is set to the beginning of
the attachment, its limit set to the length of the
attachment, and its mark is undefined.getAttachmentByteBuffer in interface XMLMessageByteBuffer view wrapping a byte
array owned by this message. If no attachment is present in this
message, returns null.public int getBinaryMetadataContentLength(int type)
getBinaryMetadataContentLength in interface XMLMessagetype - The type of binary metadata to check length for.public Collection<Integer> getBinaryMetadataTypes()
getBinaryMetadataTypes in interface XMLMessagepublic List<Long> getConsumerIdList()
XMLMessage0x00000000 - 0xFFFFFFFE, and each
one indicates that the received message matched at least one subscription
with that consumer ID on the appliance.
Consumer IDs are only present once, even if multiple subscriptions with that consumer ID each have caused a match.
The return value is null if no consumer IDs are set on the
message.
getConsumerIdList in interface XMLMessagepublic int getContentLength()
XMLMessagegetContentLength in interface XMLMessagepublic String getCorrelationId()
XMLMessagegetCorrelationId in interface XMLMessagenull, if
unset.public Object getCorrelationKey()
XMLMessageJCSMPStreamingPublishCorrelatingEventHandler.getCorrelationKey in interface XMLMessagepublic User_Cos getCos()
XMLMessagegetCos in interface XMLMessagepublic boolean getDeliverToOne()
XMLMessageFalse by default.
getDeliverToOne in interface XMLMessagetrue if this message was configured to deliver to one client only.public DeliveryMode getDeliveryMode()
XMLMessagegetDeliveryMode in interface XMLMessageDeliveryMode) representing one of the
CSMP delivery modes.public Destination getDestination()
XMLMessageQueue or Topic instance.getDestination in interface XMLMessagenull if unavailable.public String getDestinationTopicSuffix()
XMLMessagegetDestination()) does not
begin with the session's default ReplyTo base topic, then
null is returned.getDestinationTopicSuffix in interface XMLMessagepublic boolean getDiscardIndication()
XMLMessagetrue if one or more messages have been discarded
prior to the current message, else false. This indicates
congestion discards only and is not affected by message eliding.getDiscardIndication in interface XMLMessageTrue if prior messages have been discarded, else
false.XMLMessage.isElidingEligible()public String getMessageId()
XMLMessageOn the receiving side, if messages received do not have message ID set by the appliance, JCSMP automatically assigns one and guarantees its uniqueness for a particular <subscriber; message type>.
Guaranteed messages delivered from the appliance have a appliance-assigned
message ID. Messages sent or received over the Direct
delivery mode are assigned a message ID by the API, but its value is not
meaningful.
getMessageId in interface XMLMessagepublic long getMessageIdLong()
XMLMessageXMLMessage.getMessageId().getMessageIdLong in interface XMLMessagepublic MessageType getMessageType()
getMessageType in interface XMLMessageMessageType representing one of the four message types.public int getPriority()
XMLMessagegetPriority in interface XMLMessagepublic SDTMap getProperties()
XMLMessagegetProperties in interface XMLMessagenull if no user
properties map has been set on this message.public int getQueueNameLength()
getQueueNameLength in interface XMLMessagepublic int getQueueNameOffset()
getQueueNameOffset in interface XMLMessagepublic long getReceiveTimestamp()
XMLMessagegetReceiveTimestamp in interface XMLMessagepublic boolean getRedelivered()
XMLMessagegetRedelivered in interface XMLMessageboolean indicating if the message has been delivered before.public Destination getReplyTo()
XMLMessagegetReplyTo in interface XMLMessagepublic String getReplyToSuffix()
XMLMessagegetReplyToSuffix in interface XMLMessagenull if unset or ReplyTo is not a
Topic.public String getSenderID()
getSenderID in interface XMLMessagepublic String getSenderId()
XMLMessagegetSenderId in interface XMLMessagepublic Long getSendTimestamp()
getSendTimestamp in interface XMLMessagepublic Long getSenderTimestamp()
XMLMessagegetSenderTimestamp in interface XMLMessagepublic Long getSequenceNumber()
XMLMessagegetSequenceNumber in interface XMLMessageNull if it was not set on send.public boolean getTQDiscardIndication()
getTQDiscardIndication in interface XMLMessageTrue if prior messages have been discarded, else false.public long getTimeToLive()
XMLMessagegetTimeToLive in interface XMLMessagepublic int getTopicNameLength()
getTopicNameLength in interface XMLMessagepublic int getTopicNameOffset()
getTopicNameOffset in interface XMLMessagepublic byte[] getUserData()
XMLMessagehasUserData() method to check
whether user data is present on a received message.
NOTE: The maximum length of the user data is 36 bytes.
getUserData in interface XMLMessagenull
if none is present.public boolean hasContent()
XMLMessagehasContent in interface XMLMessageTrue if the message has content, false otherwise.public boolean hasAttachment()
XMLMessagehasAttachment in interface XMLMessageTrue if the message has an attachment, false otherwise.public boolean hasBinaryMetadata(int type)
hasBinaryMetadata in interface XMLMessagetype - The type of binary metadata to check for.public boolean hasUserData()
XMLMessagehasUserData in interface XMLMessagetrue if user data is present, false
otherwise.public boolean isReadOnly()
XMLMessageisReadOnly in interface XMLMessagepublic int readAttachmentBytes(byte[] byteOutputBuffer)
XMLMessageIf the length of the array is less than the number of bytes remaining to be read, the array is filled.
If the number of bytes to be read in the attachment is less than the length of the array, all attachment bytes are read into the array. Use XMLMessage.getAttachmentContentLength() to find the size of the attachment in order to provide a correctly-sized array.
readAttachmentBytes in interface XMLMessagebyteOutputBuffer - A byte array to fill with bytes from the attachment.public int readAttachmentBytes(byte[] byteOutputBuffer,
int length)
XMLMessagelength bytes from an attachment, copying the data to
the supplied byte array.
If the number of bytes to be read in the attachment is less than length,
all attachment bytes are read into the array.
readAttachmentBytes in interface XMLMessagebyteOutputBuffer - A byte array to fill with bytes from the attachment.length - The number of bytes to read.public int readAttachmentBytes(int srcPos,
byte[] byteOutputBuffer,
int destPos,
int length)
XMLMessagelength bytes from an attachment, copying the data to
the supplied byte array.
If the number of bytes to be read in the attachment is less than
length, all attachment bytes are read into the array.
Parameter ordering mimics the semantics of System#arraycopy.
readAttachmentBytes in interface XMLMessagesrcPos - The starting position in the source array.byteOutputBuffer - A destination byte array to fill.destPos - The starting position in the destination array.length - The number of bytes to read.public int readBinaryMetadataBytes(int type,
byte[] byteOutputBuffer)
readBinaryMetadataBytes in interface XMLMessagetype - The type of binary metadata to read.byteOutputBuffer - The byte array to copy the data to.public void rejectMessage()
rejectMessage in interface XMLMessagepublic void rewindAttachment()
XMLMessageXMLMessage.readAttachmentBytes(byte[]) or
XMLMessage.readAttachmentBytes(byte[], int) reads from the beginning of the attachment.rewindAttachment in interface XMLMessagepublic void setAppMessageID(String msgId)
setAppMessageID in interface XMLMessagepublic void setApplicationMessageId(String msgId)
XMLMessagesetApplicationMessageId in interface XMLMessagemsgId - The message ID.public void setAppMessageType(String appMsgType)
setAppMessageType in interface XMLMessagepublic void setApplicationMessageType(String appMsgType)
XMLMessagesetApplicationMessageType in interface XMLMessageappMsgType - The application message type.public void setCorrelationId(String id)
XMLMessagesetCorrelationId in interface XMLMessageid - The correlation ID to associate with this message.public void setCorrelationKey(Object key)
XMLMessageJCSMPStreamingPublishCorrelatingEventHandler. Only effective for
PERSISTENT and NON-PERSISTENT messages
(that is, Guaranteed Delivery).setCorrelationKey in interface XMLMessagekey - The correlation key to associate with this message.public void setCos(User_Cos cosValue)
XMLMessagesetCos in interface XMLMessagecosValue - Class of Service (CoS).public void setDeliverToOne(boolean deliverToOne)
XMLMessageFalse by default.
When a direct message has the DeliverToOne property set to true , it can be delivered only to one client. For a Guaranteed Delivery message, this behavior only applies to the "demoted" direct copy of this message.
setDeliverToOne in interface XMLMessagedeliverToOne - True to enable delivering to one client only.public void setDeliveryMode(DeliveryMode mode)
XMLMessagesetDeliveryMode in interface XMLMessagemode - An enumerated type (DeliveryMode) representing one of
the CSMP delivery modes.public void setMessageType(MessageType msgType)
setMessageType in interface XMLMessagemsgType - An enumerated type (MessageType) representing one of
the CSMP message types.public void setPriority(int priority)
XMLMessageThe valid priority value range is 0-255 with 0 as the lowest priority and 255 as the highest. Value -1 indicates the priority is not set and a default priority value is used instead.
setPriority in interface XMLMessagepriority - parameterpublic void setProperties(SDTMap props)
XMLMessageProducersetProperties in interface XMLMessageprops - The user properties map.public void setQueueNameLocation(int offset,
int length)
setQueueNameLocation in interface XMLMessageoffset - Indicates the number of bytes from the start of the metadata where the first byte of the queue name is located.length - parameterpublic void setReadOnly()
XMLMessageIllegalAccessError to be raised.setReadOnly in interface XMLMessagepublic boolean isReplyMessage()
XMLMessageisReplyMessage in interface XMLMessageboolean indicating the state of the reply field.public void setAsReplyMessage(boolean isResponse)
XMLMessagesetAsReplyMessage in interface XMLMessageisResponse - Whether to set or clear the reply attribute.public void setReplyTo(Destination destination)
XMLMessagesetReplyTo in interface XMLMessagedestination - The replyTo destination.public void setReplyToSuffix(String suffix)
XMLMessagesetReplyToSuffix in interface XMLMessagesuffix - The suffix to append when setting a new ReplyTo destination on
this message.public void setSenderID(String senderID)
setSenderID in interface XMLMessagepublic void setSenderId(String senderId)
XMLMessagesetSenderId in interface XMLMessagesenderId - The Sender ID for the message.public void setSendTimestamp(long ts)
setSendTimestamp in interface XMLMessagepublic void setSenderTimestamp(long ts)
XMLMessagesetSenderTimestamp in interface XMLMessagets - The value to set as the send timestamp.public void setSequenceNumber(long seqNum)
XMLMessagesetSequenceNumber in interface XMLMessageseqNum - The sequence number.public void setTimeToLive(long ttl)
XMLMessageA value of 0 means the message never expires. The default value is 0.
Note: Calling this method with a value of 0 explicitly resets previously set message expiration to 0.
This property is only valid for Guaranteed messages (Persistent and Non-Persistent). It has no effect when used in conjunction with other message types unless the message is promoted by the appliance to a Guaranteed message.
setTimeToLive in interface XMLMessagettl - The number of milliseconds the Guaranteed message is allowed to
live before delivery to a subscriber.public void setTopicNameLocation(int offset,
int length)
setTopicNameLocation in interface XMLMessageoffset - Indicates the number of bytes from the start of the metadata where the first byte of the Topic name is located.length - parameterpublic void setUserData(byte[] userData)
XMLMessageNOTE: The maximum length of user data is 36 bytes.
setUserData in interface XMLMessageuserData - The user data - copied into the message object.public int writeAttachment(byte[] byteInputBuffer)
XMLMessageThis method copies the input bytes into the message.
writeAttachment in interface XMLMessagebyteInputBuffer - A byte array to copy as attachment content.public int writeAttachment(byte[] byteInputBuffer,
int offset,
int length)
throws BufferUnderflowException
XMLMessageoffset or length are negative, an
IllegalArgumentException is thrown.
If length or offset result in an attempt to
read past the end of the array, a BufferUnderflowException is
thrown.
This method copies the input bytes into the message.
writeAttachment in interface XMLMessagebyteInputBuffer - A byte array to copy as attachment content.offset - The offset from which to read bytes from the input buffer.length - The number of bytes to copy.BufferUnderflowException - on errorpublic int writeAttachment(InputStream stream) throws IOException
XMLMessageThis method copies the input bytes into the message.
writeAttachment in interface XMLMessagestream - A stream from which to read attachment content.IOExceptionpublic int writeBinaryMetadataBytes(int type,
byte[] byteInputBuffer)
writeBinaryMetadataBytes in interface XMLMessagetype - The type of binary metadata to write.byteInputBuffer - The byte array to copy the data to.public int writeBinaryMetadataBytes(int type,
byte[] byteInputBuffer,
int offset,
int length)
throws BufferUnderflowException
writeBinaryMetadataBytes in interface XMLMessagetype - The type of binary metadata to write.byteInputBuffer - Byte array to copy the data to.offset - The offset from which to read bytes from the input buffer.length - The number of bytes to copy.BufferUnderflowException - on errorpublic int writeNewAttachment(byte[] byteInputBuffer)
XMLMessagewriteNewAttachment in interface XMLMessagebyteInputBuffer - A byte array to copy as attachment content.public int writeNewAttachment(byte[] byteInputBuffer,
int offset,
int length)
throws BufferUnderflowException
XMLMessageoffset or length are negative, an
IllegalArgumentException is thrown.
If length or offset result in an attempt to
read past the end of the array, a BufferUnderflowException is
thrown.writeNewAttachment in interface XMLMessagebyteInputBuffer - A byte array to copy as attachment content.offset - The offset from which to read bytes from the input buffer.length - The number of bytes to copy.BufferUnderflowExceptionpublic int writeNewAttachment(InputStream stream, int offset, int length) throws IOException
XMLMessageoffset or length are negative, an
IllegalArgumentException is thrown.writeNewAttachment in interface XMLMessagestream - A stream from which to read attachment content.offset - The offset from which to read bytes from the input stream.length - The number of bytes to read from the stream.IOExceptionpublic int writeNewAttachment(InputStream stream) throws IOException
XMLMessagewriteNewAttachment in interface XMLMessagestream - A stream from which to read attachment content.IOExceptionpublic byte[] getBytes()
BytesXMLMessageThe message content is returned when the message is read-only. Otherwise, the method returns an empty byte array.
Note that there is no guarantee that the array will have the same length
as the content; it may in fact be larger. Applications should only read
the number of bytes returned by XMLMessage.getContentLength().
getBytes in interface BytesXMLMessagepublic int readContentBytes(int srcPos,
byte[] byteOutputBuffer,
int destPos,
int length)
XMLMessagelength bytes from the message content, copying the
data to the supplied byte array.
If the number of bytes to be read in the content is less than
length, all content bytes are read into the array.
readContentBytes in interface XMLMessagesrcPos - The starting position in the source array.byteOutputBuffer - A destination byte array to fill.destPos - The starting position in the destination array.length - The number of bytes to read.public int readContentBytes(byte[] byteOutputBuffer)
XMLMessagereadContentBytes in interface XMLMessagebyteOutputBuffer - A destination byte array to fill.public int readContentBytes(byte[] byteOutputBuffer,
int length)
XMLMessagelength bytes from the message content, copying the
data to the supplied byte array.
If the number of bytes to be read in the content is less than
length, all content bytes are read into the array.
readContentBytes in interface XMLMessagebyteOutputBuffer - A destination byte array to fill.length - The number of bytes to read.public int readBytes(byte[] value)
BytesXMLMessage
If the length of array value is less than the number of
bytes remaining to be read from the message content, the array is filled.
The read mark for the message content is incremented by the number of
bytes read. A subsequent call reads from the read mark, and so on.
If the number of bytes remaining in the message content is less than the
length of array value, the bytes are read into the array.
The read mark for the message content is incremented by the number of
bytes read. The return value of the total number of bytes read is less
than the length of the array, which indicates that there are no more
bytes left to be read from the message content. The next read would then
return -1.
readBytes in interface BytesXMLMessagevalue - The buffer into which the data is read.public int readBytes(byte[] value,
int length)
BytesXMLMessagelength bytes from the message content, and copies the
data read to the supplied byte array.
If length is less than the number of bytes remaining to be
read from the message content, length bytes are read. The
read mark for the message content is incremented by the number of bytes
read. A subsequent call reads from the read mark, and so on.
If the number of bytes remaining to be read in the message content is
less than length, the remaining bytes are read into the
array. The read mark for the message content is incremented by the number
of bytes read. The return value of the total number of bytes read is less
than length, which indicates that there are no more bytes
left to be read from the message content. The next read of the message
returns -1.
If length is greater than the length of the array
value, an IndexOutOfBoundsException is thrown.
No bytes are read from the message content for this exception case.
readBytes in interface BytesXMLMessagevalue - The buffer into which the data is read.length - The number of bytes to read; this must be less than or equal to
value.length.public void rewindContent()
BytesXMLMessageBytesXMLMessage.readBytes(byte[]) or BytesXMLMessage.readBytes(byte[], int) reads from
the beginning of the message content.rewindContent in interface BytesXMLMessagepublic void writeBytes(byte[] value)
BytesXMLMessage
An application that wants to replace content, for example when publishing
the same message again with different content, can call
XMLMessage.clearContent(), then write the new data.
This method copies the input bytes into the message.
writeBytes in interface BytesXMLMessagevalue - The byte array to be written (by appending to existing data).public void writeBytes(byte[] value,
int offset,
int length)
BytesXMLMessage
An application that wants to replace content, for example when publishing
the same message again with different content, can call
XMLMessage.clearContent(), then write the new data.
This method copies the input bytes into the message.
writeBytes in interface BytesXMLMessagevalue - The byte array to be written.offset - The initial offset within the byte array.length - The number of bytes to use.public byte getStructuredMsgType()
XMLMessageisStructuredMsg()
One of the structured messages:
getStructuredMsgType in interface XMLMessagepublic void setStructuredMsgType(byte value)
XMLMessagesetStructuredMsg()
One of the structured messages:
setStructuredMsgType in interface XMLMessagevalue - structured/Unstructured message type.public boolean isStructuredMsg()
XMLMessageisStructuredMsg in interface XMLMessageTrue if the message is a structured message.public void setStructuredMsg(boolean isStructured)
XMLMessagesetStructuredMsgType().setStructuredMsg in interface XMLMessageisStructured - True if it is a structured message.public Long getCacheRequestId()
XMLMessagenull if isCacheMessage() is false.getCacheRequestId in interface XMLMessagepublic boolean isCacheMessage()
XMLMessagetrue if this message was part of a cache reply.isCacheMessage in interface XMLMessagetrue if this message was part of a cache reply.public boolean isSuspect()
XMLMessagetrue if this message was part of a cache reply that had the suspect flag set.isSuspect in interface XMLMessagetrue if this message was part of a cache reply that had the suspect flag set.public void reset()
XMLMessageJCSMPFactory.reset in interface XMLMessagepublic String dump()
XMLMessagedump(MSGDUMP_FULL).dump in interface XMLMessageString representation of the message, to be used
for debugging.public String dump(int flags)
XMLMessage
dump in interface XMLMessageflags - Flags controlling the output, such as whether to include
verbose (binary dump) informationString representation of the message, to be used
for debugging.public boolean isDMQEligible()
XMLMessagefalse, the message is discarded upon expiration. The default value is
false.
This setting is only valid for Guaranteed messages (Persistent and Non-Persistent). It has no effect when used for a Direct message unless the message is promoted by the appliance to a Guaranteed message.
isDMQEligible in interface XMLMessageboolean indicating whether the message is eligible to be moved to
a Dead Message Queue.public long getExpiration()
XMLMessageA value of 0 means the message never expires. The default value is 0.
If TimeToLive is set to a value greater than 0 before sending, getExpiration() will have one of the following values:
JCSMPProperties.CALCULATE_MESSAGE_EXPIRATION is set to true, getExpiration() returns
the sum of the message's TimeToLive and UTC value after the message is sent at the first send attempt. Otherwise,
getExpiration() returns 0.
JCSMPProperties.CALCULATE_MESSAGE_EXPIRATION
is set to true, getExpiration() returns the sum of TimeToLive and the UTC value when the message is received.
Otherwise, getExpiration returns 0.
This setting is only valid for Guaranteed messages (Persistent and Non-Persistent). It has no effect when used for a Direct message unless the message is promoted by the appliance to a Guaranteed message.
getExpiration in interface XMLMessagepublic void setDMQEligible(boolean dmqEligible)
XMLMessagefalse.
This setting is only valid for Guaranteed messages (Persistent and Non-Persistent). It has no effect when used for a Direct message unless the message is promoted by the appliance to a Guaranteed message.
setDMQEligible in interface XMLMessagedmqEligible - Whether the message is eligible to be moved to a DMQ upon expiration.public void setExpiration(long expiration)
XMLMessageThis field only serves as a reference as to when the message may expire. A value of 0 means the message never expires. The default value is 0.
Note: If TimeToLive is set to zero explicitly by application, any previously set Expiration is reset to 0.
This setting is only valid for Guaranteed messages (Persistent and Non-Persistent). It has no effect when used for a Direct message unless the message is promoted by the appliance to a Guaranteed message.
setExpiration in interface XMLMessageexpiration - parameterpublic boolean isElidingEligible()
XMLMessage
Message eliding enables filtering of data to avoid transmitting every
single update to a subscribing client. It can be used to overcome slow
consumers or any situation where a slower message rate is desired.
Eliding can be applied to messages delivered to subscribers in
DIRECT delivery mode.
Time-based eliding ensures that subscriber applications always receive only the most current update of a published topic at a rate that they can manage. By limiting the incoming message rate, a subscriber application is able to avoid a message backlog filled with outdated messages. This property does not indicate whether messages were elided or provide information about the subscriber profile eliding configuration.
isElidingEligible in interface XMLMessagepublic void setElidingEligible(boolean eliding)
XMLMessagesetElidingEligible in interface XMLMessageeliding - Whether the message is eligible for eliding.isElidingEligible() for more information about
this feature.public Long getTopicSequenceNumber()
XMLMessagegetTopicSequenceNumber in interface XMLMessageNull if it was not generated by the appliance.public boolean isAckImmediately()
XMLMessagefalse.
This setting is only valid for Guaranteed messages (Persistent and Non-Persistent). It has no effect when used for a Direct message.
This property, when set by a publisher, may or may not be removed by the appliance prior to delivery to a consumer, so message consumers must not rely on this property being present.
isAckImmediately in interface XMLMessageboolean indicating whether the message should be ACKed by the appliance immediately upon receipt.public void setAckImmediately(boolean ackImmediately)
XMLMessagefalse.
This setting is only valid for Guaranteed messages (Persistent and Non-Persistent). It has no effect when used for a Direct message.
This property, when set by a publisher, may or may not be removed by the appliance prior to delivery to a consumer, so message consumers must not rely on this property being present.
setAckImmediately in interface XMLMessageackImmediately - Whether the message should be ACKed by the appliance immediately upon receipt.public long getAckMessageId()
getAckMessageId in interface XMLMessagepublic String getHTTPContentType()
XMLMessagegetHTTPContentType in interface XMLMessagenull if it is not set.public void setHTTPContentType(String contentType)
XMLMessagesetHTTPContentType in interface XMLMessagecontentType - The HTTP content type header value.public String getHTTPContentEncoding()
XMLMessagegetHTTPContentEncoding in interface XMLMessagenull if it is not set.public void setHTTPContentEncoding(String contentEncoding)
XMLMessagesetHTTPContentEncoding in interface XMLMessagecontentEncoding - The HTTP content encoding header value.Copyright 2004-2020 Solace Corporation. All rights reserved.