Class 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.
    • Constructor Summary

      Constructors 
      Constructor Description
      Message​(java.lang.Object payload)
      Initializes an instance of class Message.
      Message​(java.lang.Object payload, TimeSpan timeSpan)
      Initializes an instance of class Message.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Date getCreationTime()
      This property gets the time of creation 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)
      This property sets the time of creation 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.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Message

        public Message​(java.lang.Object payload)
        Initializes an instance of class Message.
        Parameters:
        payload - This property specifies the payload of the message.
      • Message

        public Message​(java.lang.Object payload,
                       TimeSpan timeSpan)
        Initializes an instance of class Message.
        Parameters:
        payload - This property specifies the payload of the message.
        timeSpan - A constant value that indicates that messages have been added into the cache without expiry.
    • 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()
        This property gets the time of creation in DateTime for the message.
        Returns:
        Creation time of message in DateTime.
      • setCreationTime

        public final void setCreationTime​(java.util.Date value)
        This property sets the time of creation in DateTime for the message.
        Parameters:
        value - Creation time of message in DateTime.