Interface MessageBuilder

All Known Implementing Classes:
MessageBuilderImpl

@Deprecated public interface MessageBuilder
Deprecated.
since 2.0. Use TypedMessageBuilder as returned by Producer#newMessage() to create a new message builder.
Message builder factory. Use this class to create messages to be send to the Pulsar producer
  • Method Details

    • create

      static MessageBuilder create()
      Deprecated.
    • build

      org.apache.pulsar.client.api.Message<byte[]> build()
      Deprecated.
      Finalize the immutable message.
      Returns:
      a Message ready to be sent through a Producer
    • setContent

      MessageBuilder setContent(byte[] data)
      Deprecated.
      Set the content of the message.
      Parameters:
      data - array containing the payload
    • setContent

      MessageBuilder setContent(byte[] data, int offset, int length)
      Deprecated.
      Set the content of the message.
      Parameters:
      data - array containing the payload
      offset - offset into the data array
      length - length of the payload starting from the above offset
    • setContent

      MessageBuilder setContent(ByteBuffer buf)
      Deprecated.
      Set the content of the message.
      Parameters:
      buf - a ByteBuffer with the payload of the message
    • setProperty

      MessageBuilder setProperty(String name, String value)
      Deprecated.
      Sets a new property on a message.
      Parameters:
      name - the name of the property
      value - the associated value
    • setProperties

      MessageBuilder setProperties(Map<String,String> properties)
      Deprecated.
      Add all the properties in the provided map.
    • setKey

      MessageBuilder setKey(String key)
      Deprecated.
      Sets the key of the message for routing policy.
      Parameters:
      key -
    • setEventTime

      MessageBuilder setEventTime(long timestamp)
      Deprecated.
      Set 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.

      Since:
      1.20.0
    • setSequenceId

      MessageBuilder setSequenceId(long sequenceId)
      Deprecated.
      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:
      sequenceId - the sequence id to assign to the current message
      Since:
      1.20.0
    • setReplicationClusters

      MessageBuilder setReplicationClusters(List<String> clusters)
      Deprecated.
      Override the replication clusters for this message.
      Parameters:
      clusters -
    • disableReplication

      MessageBuilder disableReplication()
      Deprecated.
      Disable replication for this message.