Package org.apache.pulsar.client.api.v5
Interface MessageMetadata<T,BuilderT extends MessageMetadata<T,BuilderT>>
- Type Parameters:
T- the type of the message valueBuilderT- 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 Summary
Modifier and TypeMethodDescriptiondeliverAfter(Duration delay) Request delayed delivery: the message becomes visible to consumers after the given delay.Request delayed delivery: the message becomes visible to consumers at the given time.Set the event time of the message.Set the message key.properties(Map<String, String> properties) Add multiple properties to the message.Add a single property to the message.replicationClusters(List<String> clusters) Restrict geo-replication to the specified clusters only.sequenceId(long sequenceId) Set the sequence ID for producer deduplication.transaction(Transaction txn) Associate this message with a transaction.Set the message value.
-
Method Details
-
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
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
Associate this message with a transaction.- Parameters:
txn- the transaction to associate with this message- Returns:
- this builder instance for chaining
-
property
Add a single property to the message.- Parameters:
name- the property keyvalue- the property value- Returns:
- this builder instance for chaining
-
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
Set the event time of the message.- Parameters:
eventTime- the application-defined event time for the message- Returns:
- this builder instance for chaining
-
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
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
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
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
-