Class Message

java.lang.Object
io.adamantic.quicknote.types.Message

public class Message extends Object
Simple representation of a message to be sent over a channel.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    A very basic message id generator.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Default content type for messages.
    static final Map<String,String>
    Default headers for messages.
    static final byte[]
    Default payload for messages.
    static final String
    Default routing key for messages.
    static final int
    Default time-to-live for messages.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Message(long id)
    Creates a new message with a specific id, rather than asking the ID generator to generate a new one.
  • Method Summary

    Modifier and Type
    Method
    Description
    static long
    Delegates message id generation to the installed id generator.
    int
    Decrements the time to live of this message.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_ROUTING

      public static final String DEFAULT_ROUTING
      Default routing key for messages.
      See Also:
    • DEFAULT_CONTENT_TYPE

      public static final String DEFAULT_CONTENT_TYPE
      Default content type for messages.
      See Also:
    • DEFAULT_HEADERS

      public static final Map<String,String> DEFAULT_HEADERS
      Default headers for messages.
    • DEFAULT_PAYLOAD

      public static final byte[] DEFAULT_PAYLOAD
      Default payload for messages.
    • DEFAULT_TTL

      public static final int DEFAULT_TTL
      Default time-to-live for messages.
      See Also:
  • Constructor Details

    • Message

      public Message(long id)
      Creates a new message with a specific id, rather than asking the ID generator to generate a new one. Especially useful for incominc messages, where the id is already generated by the sender.
      Parameters:
      id - the message id
  • Method Details

    • touchTtl

      public int touchTtl()
      Decrements the time to live of this message. If the time to live reaches zero, a TimeToLiveExpired exception is thrown (unchecked).
      Returns:
      the updated time to live
    • nextId

      public static long nextId()
      Delegates message id generation to the installed id generator.
      Returns:
      the next message id