pulsar-client-cpp
Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
pulsar::MessageBuilder Class Reference
Inheritance diagram for pulsar::MessageBuilder:
pulsar::TypedMessageBuilder< T > pulsar::TypedMessageBuilder< std::string >

Public Types

typedef std::map< std::string, std::string > StringMap
 

Public Member Functions

Message build ()
 
MessageBuildersetContent (const void *data, size_t size)
 
MessageBuildersetContent (const std::string &data)
 
MessageBuildersetContent (std::string &&data)
 
MessageBuildersetContent (const KeyValue &data)
 
MessageBuildersetAllocatedContent (void *data, size_t size)
 
MessageBuildersetProperty (const std::string &name, const std::string &value)
 
MessageBuildersetProperties (const StringMap &properties)
 
MessageBuildersetPartitionKey (const std::string &partitionKey)
 
MessageBuildersetOrderingKey (const std::string &orderingKey)
 
MessageBuildersetDeliverAfter (const std::chrono::milliseconds delay)
 
MessageBuildersetDeliverAt (uint64_t deliveryTimestamp)
 
MessageBuildersetEventTimestamp (uint64_t eventTimestamp)
 
MessageBuildersetSequenceId (int64_t sequenceId)
 
MessageBuildersetReplicationClusters (const std::vector< std::string > &clusters)
 
MessageBuilderdisableReplication (bool flag)
 
MessageBuildercreate ()
 

Protected Member Functions

const char * data () const
 
std::size_t size () const
 

Friends

class PulsarWrapper
 

Member Function Documentation

◆ build()

Message pulsar::MessageBuilder::build ( )

Finalize the immutable message

◆ create()

MessageBuilder& pulsar::MessageBuilder::create ( )

create a empty message, with no properties or data

◆ disableReplication()

MessageBuilder& pulsar::MessageBuilder::disableReplication ( bool  flag)

Do not replicate this message

Parameters
flagif true, disable replication, otherwise use default replication

◆ setAllocatedContent()

MessageBuilder& pulsar::MessageBuilder::setAllocatedContent ( void *  data,
size_t  size 
)

Set content of the message to a buffer already allocated by the caller. No copies of this buffer will be made. The caller is responsible to ensure the memory buffer is valid until the message has been persisted (or an error is returned).

◆ setContent() [1/4]

MessageBuilder& pulsar::MessageBuilder::setContent ( const KeyValue data)

Set the key value content of the message

Parameters
datathe content of the key value.

◆ setContent() [2/4]

MessageBuilder& pulsar::MessageBuilder::setContent ( const std::string &  data)

Set the content of the message

Parameters
datathe content of the message.
See also
setContent(const void*, size_t)

◆ setContent() [3/4]

MessageBuilder& pulsar::MessageBuilder::setContent ( const void *  data,
size_t  size 
)

Set content of the message. The given data is copied into message.

◆ setContent() [4/4]

MessageBuilder& pulsar::MessageBuilder::setContent ( std::string &&  data)

Set the content of the message

Parameters
datathe content of the message. The given data is moved into message.

◆ setDeliverAfter()

MessageBuilder& pulsar::MessageBuilder::setDeliverAfter ( const std::chrono::milliseconds  delay)

Specify a delay for the delivery of the messages.

Parameters
delaythe delay in milliseconds

◆ setDeliverAt()

MessageBuilder& pulsar::MessageBuilder::setDeliverAt ( uint64_t  deliveryTimestamp)

Specify the this message should not be delivered earlier than the specified timestamp.

Parameters
deliveryTimestampUTC based timestamp in milliseconds

◆ setEventTimestamp()

MessageBuilder& pulsar::MessageBuilder::setEventTimestamp ( uint64_t  eventTimestamp)

Set the event timestamp for the message.

◆ setOrderingKey()

MessageBuilder& pulsar::MessageBuilder::setOrderingKey ( const std::string &  orderingKey)

set ordering key used for key_shared subscriptions

Parameters
theordering key for the message

◆ setPartitionKey()

MessageBuilder& pulsar::MessageBuilder::setPartitionKey ( const std::string &  partitionKey)

set partition key for message routing and topic compaction

Parameters
hashof this key is used to determine message's topic partition

◆ setProperties()

MessageBuilder& pulsar::MessageBuilder::setProperties ( const StringMap &  properties)

Add all the properties in the provided map

◆ setProperty()

MessageBuilder& pulsar::MessageBuilder::setProperty ( const std::string &  name,
const std::string &  value 
)

Sets a new property on a message.

Parameters
namethe name of the property
valuethe associated value

◆ setReplicationClusters()

MessageBuilder& pulsar::MessageBuilder::setReplicationClusters ( const std::vector< std::string > &  clusters)

override namespace replication clusters. note that it is the caller's responsibility to provide valid cluster names, and that all clusters have been previously configured as topics.

given an empty list, the message will replicate per the namespace configuration.

Parameters
clusterswhere to send this message.

◆ setSequenceId()

MessageBuilder& pulsar::MessageBuilder::setSequenceId ( int64_t  sequenceId)

Specify 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:

  1. sequenceId >= 0
  2. Sequence id for a message needs to be greater than sequence id for earlier messages: sequenceId(N+1) > sequenceId(N)
  3. It's not necessary for sequence ids to be consecutive. There can be holes between messages. Eg. the sequenceId could represent an offset or a cumulative size.
Parameters
sequenceIdthe sequence id to assign to the current message
Since
1.20.0

The documentation for this class was generated from the following file: