Interface MessageMetadata<T,BuilderT extends MessageMetadata<T,BuilderT>>

Type Parameters:
T - the type of the message value
BuilderT - the concrete builder type (for fluent returns)
All Known Subinterfaces:
AsyncMessageBuilder<T>, MessageBuilder<T>

public interface MessageMetadata<T,BuilderT extends MessageMetadata<T,BuilderT>>
Common message metadata that can be set on any outgoing message.

This is the shared base for MessageBuilder (sync) and AsyncMessageBuilder (async). The self-referential type parameter BuilderT enables fluent chaining on both subtypes.

  • Method Details

    • value

      BuilderT value(T value)
      Set the message value.
      Parameters:
      value - the message payload to be serialized using the producer's schema
      Returns:
      this builder instance for chaining
    • key

      BuilderT key(String key)
      Set the message key. Messages with the same key are guaranteed to be delivered in order to stream consumers. Queue consumers may use the key for routing.
      Parameters:
      key - the message key used for ordering and routing
      Returns:
      this builder instance for chaining
    • transaction

      BuilderT transaction(Transaction txn)
      Associate this message with a transaction.
      Parameters:
      txn - the transaction to associate with this message
      Returns:
      this builder instance for chaining
    • property

      BuilderT property(String name, String value)
      Add a single property to the message.
      Parameters:
      name - the property key
      value - the property value
      Returns:
      this builder instance for chaining
    • properties

      BuilderT properties(Map<String,String> properties)
      Add multiple properties to the message.
      Parameters:
      properties - a map of property key-value pairs to attach to the message
      Returns:
      this builder instance for chaining
    • eventTime

      BuilderT eventTime(Instant eventTime)
      Set the event time of the message.
      Parameters:
      eventTime - the application-defined event time for the message
      Returns:
      this builder instance for chaining
    • sequenceId

      BuilderT sequenceId(long sequenceId)
      Set the sequence ID for producer deduplication.
      Parameters:
      sequenceId - the sequence ID to assign to the message for deduplication purposes
      Returns:
      this builder instance for chaining
    • deliverAfter

      BuilderT deliverAfter(Duration delay)
      Request delayed delivery: the message becomes visible to consumers after the given delay.
      Parameters:
      delay - the duration to wait before the message becomes visible to consumers
      Returns:
      this builder instance for chaining
    • deliverAt

      BuilderT deliverAt(Instant timestamp)
      Request delayed delivery: the message becomes visible to consumers at the given time.
      Parameters:
      timestamp - the absolute time at which the message becomes visible to consumers
      Returns:
      this builder instance for chaining
    • replicationClusters

      BuilderT replicationClusters(List<String> clusters)
      Restrict geo-replication to the specified clusters only.
      Parameters:
      clusters - the list of cluster names to which this message should be replicated
      Returns:
      this builder instance for chaining