public class MessageBuilderImpl<T> extends Object implements MessageBuilder<T>
Constructor and Description |
---|
MessageBuilderImpl(Schema<T> schema) |
Modifier and Type | Method and Description |
---|---|
Message<T> |
build()
Finalize the immutable message
|
MessageBuilder<T> |
disableReplication()
Disable replication for this message.
|
MessageBuilder<T> |
setContent(byte[] data)
Set the content of the message
|
MessageBuilder<T> |
setContent(byte[] data,
int offet,
int length)
Set the content of the message
|
MessageBuilder<T> |
setContent(ByteBuffer buf)
Set the content of the message
|
MessageBuilder<T> |
setEventTime(long timestamp)
Set the event time for a given message.
|
MessageBuilder<T> |
setKey(String key)
Sets the key of the message for routing policy
|
MessageBuilder<T> |
setProperties(Map<String,String> properties)
Add all the properties in the provided map
|
MessageBuilder<T> |
setProperty(String name,
String value)
Sets a new property on a message.
|
MessageBuilder<T> |
setReplicationClusters(List<String> clusters)
Override the replication clusters for this message.
|
MessageBuilder<T> |
setSequenceId(long sequenceId)
Specify a custom sequence id for the message being published.
|
MessageBuilder<T> |
setValue(T value)
Set a domain object on the message
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
create, create
public Message<T> build()
MessageBuilder
build
in interface MessageBuilder<T>
Message
ready to be sent through a Producer
public MessageBuilder<T> setValue(T value)
MessageBuilder
setValue
in interface MessageBuilder<T>
value
- the domain objectpublic MessageBuilder<T> setContent(byte[] data)
MessageBuilder
setContent
in interface MessageBuilder<T>
data
- array containing the payloadpublic MessageBuilder<T> setContent(byte[] data, int offet, int length)
MessageBuilder
setContent
in interface MessageBuilder<T>
data
- array containing the payloadoffet
- offset into the data arraylength
- length of the payload starting from the above offsetpublic MessageBuilder<T> setContent(ByteBuffer buf)
MessageBuilder
setContent
in interface MessageBuilder<T>
buf
- a ByteBuffer
with the payload of the messagepublic MessageBuilder<T> setProperties(Map<String,String> properties)
MessageBuilder
setProperties
in interface MessageBuilder<T>
public MessageBuilder<T> setProperty(String name, String value)
MessageBuilder
setProperty
in interface MessageBuilder<T>
name
- the name of the propertyvalue
- the associated valuepublic MessageBuilder<T> setKey(String key)
MessageBuilder
setKey
in interface MessageBuilder<T>
public MessageBuilder<T> setEventTime(long timestamp)
MessageBuilder
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.
setEventTime
in interface MessageBuilder<T>
public MessageBuilder<T> setSequenceId(long sequenceId)
MessageBuilder
The sequence id can be used for deduplication purposes and it needs to follow these rules:
sequenceId >= 0
sequenceId(N+1) > sequenceId(N)
sequenceId
could represent an offset or a cumulative size.
setSequenceId
in interface MessageBuilder<T>
sequenceId
- the sequence id to assign to the current messagepublic MessageBuilder<T> setReplicationClusters(List<String> clusters)
MessageBuilder
setReplicationClusters
in interface MessageBuilder<T>
public MessageBuilder<T> disableReplication()
MessageBuilder
disableReplication
in interface MessageBuilder<T>
Copyright © 2017–2018 Apache Software Foundation. All rights reserved.