Class Message
- java.lang.Object
-
- com.alachisoft.ncache.runtime.caching.Message
-
public class Message extends java.lang.Object
A message contains the actual data object which is sent by the publisher and delivered to the interested subscribers for the topic.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Date
getCreationTime()
Creation time in DateTime for the message.TimeSpan
getExpirationTime()
ExpirationTime of TimeSpan type after which the message is expired from the topic.java.lang.String
getMessageId()
Auto generated ID for the message, as same messages can be stored on different topics.java.lang.Object
getPayload()
The actual data object of interest for subscribers, for example, Order.<T> T
getPayloadAsJson(java.lang.Class<?> cls)
This method is used to get underlying payload that is stored in json form.void
setCreationTime(java.util.Date value)
Creation time in DateTime for the message.void
setExpirationTime(TimeSpan value)
Sets the expiration time of the message.void
setMessageId(java.lang.String value)
Sets the message id of the message.void
setSerializationDataInternal(PayloadDeserializer serializer, java.lang.Object serializePayload)
This method is only created for internal use, it is not recommended to use it
-
-
-
Constructor Detail
-
Message
public Message(java.lang.Object payload)
Initializes an instance of Message.- Parameters:
payload
- Payload of message.
-
Message
public Message(java.lang.Object payload, TimeSpan timeSpan)
Initializes an instance of Message.- Parameters:
payload
- Payload of message.timeSpan
- Expiry time of message.
-
-
Method Detail
-
getMessageId
public final java.lang.String getMessageId()
Auto generated ID for the message, as same messages can be stored on different topics.- Returns:
- Message id of the message.
-
setMessageId
public final void setMessageId(java.lang.String value)
Sets the message id of the message.- Parameters:
value
- The id to be set to message.
-
getExpirationTime
public final TimeSpan getExpirationTime()
ExpirationTime of TimeSpan type after which the message is expired from the topic. This can also accept null value, which will ensure that the message is not expired from the topic. In case of no expiration time specified, null is considered as default.- Returns:
- Timespan that indicates the expiration time of the message.
-
setExpirationTime
public final void setExpirationTime(TimeSpan value)
Sets the expiration time of the message.- Parameters:
value
- The value that is to be set as expiration time.
-
getPayload
public final java.lang.Object getPayload()
The actual data object of interest for subscribers, for example, Order.- Returns:
- The underlying payload of the message.
-
setSerializationDataInternal
public final void setSerializationDataInternal(PayloadDeserializer serializer, java.lang.Object serializePayload)
This method is only created for internal use, it is not recommended to use it- Parameters:
serializer
-serializePayload
-
-
getPayloadAsJson
public final <T> T getPayloadAsJson(java.lang.Class<?> cls) throws OperationFailedException, com.fasterxml.jackson.core.JsonProcessingException
This method is used to get underlying payload that is stored in json form.- Type Parameters:
T
- Specifies the type of payload.- Parameters:
cls
- Specifies the class of payload.- Returns:
- The json deserialized payload.
- Throws:
OperationFailedException
com.fasterxml.jackson.core.JsonProcessingException
-
getCreationTime
public final java.util.Date getCreationTime()
Creation time in DateTime for the message.- Returns:
- The date that specifies creation time of message.
-
setCreationTime
public final void setCreationTime(java.util.Date value)
Creation time in DateTime for the message.- Parameters:
value
- The creation time of the message.
-
-