Interface ImmutableMessage

All Superinterfaces:
Acknowledgeable, Indexable
All Known Implementing Classes:
SerializationMemoizingMessage

public interface ImmutableMessage extends Indexable, Acknowledgeable
The purpose of this interface is to provide access to certain properties of a Message while ensuring that it can't be changed anymore. This allows precomputation and re-use of e.g. the serialized JSON of a message (see Indexable.serialize(SerializationContext) while ensuring that the precomputed value does not become invalid when the message content would be changed.

For example, the interface can be used in the output path to compute the space required by a Message in a batch request to OpenSearch. Batch computation happens early in the process and when the actual index request is to be sent, the precomputed serialized value can be re-used with certainty that the message has not been altered in the meantime.

  • Method Details

    • wrap

      static ImmutableMessage wrap(Message message)
    • getId

      String getId()
      Description copied from interface: Indexable
      Returns the id to address the document in Elasticsearch. Depending on the implementation this might return a UUID or ULID This method should only be used where backwards compatibility is needed. Newer code should use Indexable.getMessageId() instead.
      Specified by:
      getId in interface Indexable
    • getIndexSets

      com.google.common.collect.ImmutableSet<IndexSet> getIndexSets()
    • getFields

      com.google.common.collect.ImmutableMap<String,Object> getFields()
    • getMessage

      String getMessage()
    • getField

      Object getField(String key)
    • getSource

      String getSource()
    • getStreamIds

      com.google.common.collect.ImmutableSet<String> getStreamIds()