Package org.apache.pulsar.client.impl
Class MessageBuilderImpl
java.lang.Object
org.apache.pulsar.client.impl.MessageBuilderImpl
- All Implemented Interfaces:
MessageBuilder
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.pulsar.client.api.Message<byte[]>build()Finalize the immutable message.Disable replication for this message.setContent(byte[] data) Set the content of the message.setContent(byte[] data, int offet, int length) Set the content of the message.setContent(ByteBuffer buf) Set the content of the message.setEventTime(long timestamp) Set the event time for a given message.Sets the key of the message for routing policy.setProperties(Map<String, String> properties) Add all the properties in the provided map.setProperty(String name, String value) Sets a new property on a message.setReplicationClusters(List<String> clusters) Override the replication clusters for this message.setSequenceId(long sequenceId) Specify a custom sequence id for the message being published.
-
Constructor Details
-
MessageBuilderImpl
public MessageBuilderImpl()
-
-
Method Details
-
build
public org.apache.pulsar.client.api.Message<byte[]> build()Description copied from interface:MessageBuilderFinalize the immutable message.- Specified by:
buildin interfaceMessageBuilder- Returns:
- a
Messageready to be sent through aProducer
-
setContent
Description copied from interface:MessageBuilderSet the content of the message.- Specified by:
setContentin interfaceMessageBuilder- Parameters:
data- array containing the payload
-
setContent
Description copied from interface:MessageBuilderSet the content of the message.- Specified by:
setContentin interfaceMessageBuilder- Parameters:
data- array containing the payloadoffet- offset into the data arraylength- length of the payload starting from the above offset
-
setContent
Description copied from interface:MessageBuilderSet the content of the message.- Specified by:
setContentin interfaceMessageBuilder- Parameters:
buf- aByteBufferwith the payload of the message
-
setProperties
Description copied from interface:MessageBuilderAdd all the properties in the provided map.- Specified by:
setPropertiesin interfaceMessageBuilder
-
setProperty
Description copied from interface:MessageBuilderSets a new property on a message.- Specified by:
setPropertyin interfaceMessageBuilder- Parameters:
name- the name of the propertyvalue- the associated value
-
setKey
Description copied from interface:MessageBuilderSets the key of the message for routing policy.- Specified by:
setKeyin interfaceMessageBuilder
-
setEventTime
Description copied from interface:MessageBuilderSet the event time for a given message.Applications can retrieve the event time by calling
Message.getEventTime().Note: currently pulsar doesn't support event-time based index. so the subscribers can't seek the messages by event time.
- Specified by:
setEventTimein interfaceMessageBuilder
-
setSequenceId
Description copied from interface:MessageBuilderSpecify a custom sequence id for the message being published.The sequence id can be used for deduplication purposes and it needs to follow these rules:
sequenceId >= 0- Sequence id for a message needs to be greater than sequence id for earlier messages:
sequenceId(N+1) > sequenceId(N) - It's not necessary for sequence ids to be consecutive. There can be holes between messages. Eg. the
sequenceIdcould represent an offset or a cumulative size.
- Specified by:
setSequenceIdin interfaceMessageBuilder- Parameters:
sequenceId- the sequence id to assign to the current message
-
setReplicationClusters
Description copied from interface:MessageBuilderOverride the replication clusters for this message.- Specified by:
setReplicationClustersin interfaceMessageBuilder
-
disableReplication
Description copied from interface:MessageBuilderDisable replication for this message.- Specified by:
disableReplicationin interfaceMessageBuilder
-