Class Message<P>

java.lang.Object
de.otto.synapse.message.Message<P>
Type Parameters:
P - The type of the Message payload
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
TextMessage

public class Message<P> extends Object implements Serializable
A Message is an atomic packet of data that can be transmitted on a channel.

Message

Thus to transmit data, an application must break the data into one or more packets, wrap each packet as a message, and then send the message on a channel. Likewise, a receiver application receives a message and must extract the data from the message to process it.

The message system will try repeatedly to deliver the message (e.g., transmit it from the sender to the receiver) until it succeeds.

See Also:
  • Constructor Details

    • Message

      protected Message(@Nonnull Key key, @Nonnull Header header, @Nullable P payload)
  • Method Details

    • message

      public static <P> Message<P> message(@Nonnull Key key, @Nullable P payload)
    • message

      public static <P> Message<P> message(@Nonnull Key key, @Nonnull Header header, @Nullable P payload)
    • message

      public static <P> Message<P> message(@Nonnull String key, @Nullable P payload)
    • message

      public static <P> Message<P> message(@Nonnull String key, @Nonnull Header header, @Nullable P payload)
    • getKey

      @Nonnull public Key getKey()
    • getPayload

      @Nullable public P getPayload()
    • getHeader

      @Nonnull public Header getHeader()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • builder

      public static <P> Message.Builder<P> builder(Class<P> payloadType)
    • copyOf

      public static <P> Message.Builder<P> copyOf(Message<P> message)