PulsarClient.newProducer()
to construct and configure a Producer
instance@Deprecated
public class ProducerConfiguration
extends Object
implements Serializable
Modifier and Type | Class and Description |
---|---|
static class |
ProducerConfiguration.HashingScheme
Deprecated.
|
static class |
ProducerConfiguration.MessageRoutingMode
Deprecated.
|
Constructor and Description |
---|
ProducerConfiguration()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
addEncryptionKey(String key)
Deprecated.
Add public encryption key, used by producer to encrypt the data key.
|
boolean |
getBatchingEnabled()
Deprecated.
Return the flag whether automatic message batching is enabled or not.
|
int |
getBatchingMaxMessages()
Deprecated.
|
long |
getBatchingMaxPublishDelayMs()
Deprecated.
|
boolean |
getBlockIfQueueFull()
Deprecated.
|
CompressionType |
getCompressionType()
Deprecated.
|
ProducerCryptoFailureAction |
getCryptoFailureAction()
Deprecated.
|
CryptoKeyReader |
getCryptoKeyReader()
Deprecated.
|
Set<String> |
getEncryptionKeys()
Deprecated.
|
ProducerConfiguration.HashingScheme |
getHashingScheme()
Deprecated.
|
Optional<Long> |
getInitialSequenceId()
Deprecated.
|
int |
getMaxPendingMessages()
Deprecated.
|
int |
getMaxPendingMessagesAcrossPartitions()
Deprecated.
|
MessageRouter |
getMessageRouter()
Deprecated.
Get the message router set by
setMessageRouter(MessageRouter) . |
MessageRouter |
getMessageRouter(int numPartitions)
Deprecated.
since 1.22.0-incubating. numPartitions is already passed as parameter in
MessageRouter.choosePartition(Message, TopicMetadata) . |
ProducerConfiguration.MessageRoutingMode |
getMessageRoutingMode()
Deprecated.
Get the message routing mode for the partitioned producer.
|
ProducerConfigurationData |
getProducerConfigurationData()
Deprecated.
|
String |
getProducerName()
Deprecated.
|
Map<String,String> |
getProperties()
Deprecated.
|
long |
getSendTimeoutMs()
Deprecated.
|
boolean |
isEncryptionEnabled()
Deprecated.
Returns true if encryption keys are added
|
void |
removeEncryptionKey(String key)
Deprecated.
|
ProducerConfiguration |
setBatchingEnabled(boolean batchMessagesEnabled)
Deprecated.
Control whether automatic batching of messages is enabled for the producer.
|
ProducerConfiguration |
setBatchingMaxMessages(int batchMessagesMaxMessagesPerBatch)
Deprecated.
Set the maximum number of messages permitted in a batch.
|
ProducerConfiguration |
setBatchingMaxPublishDelay(long batchDelay,
TimeUnit timeUnit)
Deprecated.
Set the time period within which the messages sent will be batched default: 10ms if batch messages are
enabled.
|
ProducerConfiguration |
setBlockIfQueueFull(boolean blockIfQueueFull)
Deprecated.
Set whether the
Producer.send(T) and Producer.sendAsync(T) operations should block when the outgoing
message queue is full. |
ProducerConfiguration |
setCompressionType(CompressionType compressionType)
Deprecated.
Set the compression type for the producer.
|
void |
setCryptoFailureAction(ProducerCryptoFailureAction action)
Deprecated.
Sets the ProducerCryptoFailureAction to the value specified
|
ProducerConfiguration |
setCryptoKeyReader(CryptoKeyReader cryptoKeyReader)
Deprecated.
Sets a
CryptoKeyReader |
ProducerConfiguration |
setHashingScheme(ProducerConfiguration.HashingScheme hashingScheme)
Deprecated.
|
ProducerConfiguration |
setInitialSequenceId(long initialSequenceId)
Deprecated.
Set the baseline for the sequence ids for messages published by the producer.
|
ProducerConfiguration |
setMaxPendingMessages(int maxPendingMessages)
Deprecated.
Set the max size of the queue holding the messages pending to receive an acknowledgment from the broker.
|
void |
setMaxPendingMessagesAcrossPartitions(int maxPendingMessagesAcrossPartitions)
Deprecated.
Set the number of max pending messages across all the partitions
|
ProducerConfiguration |
setMessageRouter(MessageRouter messageRouter)
Deprecated.
Set a custom message routing policy by passing an implementation of MessageRouter
|
ProducerConfiguration |
setMessageRoutingMode(ProducerConfiguration.MessageRoutingMode messageRouteMode)
Deprecated.
Set the message routing mode for the partitioned producer.
|
void |
setProducerName(String producerName)
Deprecated.
Specify a name for the producer
|
ProducerConfiguration |
setProperties(Map<String,String> properties)
Deprecated.
Add all the properties in the provided map
|
ProducerConfiguration |
setProperty(String key,
String value)
Deprecated.
Set a name/value property with this producer.
|
ProducerConfiguration |
setSendTimeout(int sendTimeout,
TimeUnit unit)
Deprecated.
Set the send timeout (default: 30 seconds)
|
public String getProducerName()
public void setProducerName(String producerName)
If not assigned, the system will generate a globally unique name which can be access with
Producer.getProducerName()
.
When specifying a name, it is app to the user to ensure that, for a given topic, the producer name is unique across all Pulsar's clusters.
If a producer with the same name is already connected to a particular topic, the
PulsarClient.createProducer(String)
operation will fail with PulsarClientException.ProducerBusyException
.
producerName
- the custom name to use for the producerpublic long getSendTimeoutMs()
public ProducerConfiguration setSendTimeout(int sendTimeout, TimeUnit unit)
If a message is not acknowledged by the server before the sendTimeout expires, an error will be reported.
sendTimeout
- the send timeoutunit
- the time unit of the sendTimeout
public int getMaxPendingMessages()
public ProducerConfiguration setMaxPendingMessages(int maxPendingMessages)
When the queue is full, by default, all calls to Producer.send(T)
and Producer.sendAsync(T)
will fail
unless blockIfQueueFull is set to true. Use setBlockIfQueueFull(boolean)
to change the blocking behavior.
maxPendingMessages
- public ProducerConfiguration.HashingScheme getHashingScheme()
public ProducerConfiguration setHashingScheme(ProducerConfiguration.HashingScheme hashingScheme)
public int getMaxPendingMessagesAcrossPartitions()
public void setMaxPendingMessagesAcrossPartitions(int maxPendingMessagesAcrossPartitions)
This setting will be used to lower the max pending messages for each partition
(setMaxPendingMessages(int)
), if the total exceeds the configured value.
maxPendingMessagesAcrossPartitions
- public boolean getBlockIfQueueFull()
Producer.send(T)
and Producer.sendAsync(T)
operations when the
pending queue is fullpublic ProducerConfiguration setBlockIfQueueFull(boolean blockIfQueueFull)
Producer.send(T)
and Producer.sendAsync(T)
operations should block when the outgoing
message queue is full.
Default is false
. If set to false
, send operations will immediately fail with
PulsarClientException.ProducerQueueIsFullError
when there is no space left in pending queue.
blockIfQueueFull
- whether to block Producer.send(T)
and Producer.sendAsync(T)
operations on queue fullpublic ProducerConfiguration setMessageRoutingMode(ProducerConfiguration.MessageRoutingMode messageRouteMode)
messageRouteMode
- message routing mode.ProducerConfiguration.MessageRoutingMode
public ProducerConfiguration.MessageRoutingMode getMessageRoutingMode()
ProducerConfiguration.MessageRoutingMode.RoundRobinPartition
public ProducerConfiguration setCompressionType(CompressionType compressionType)
By default, message payloads are not compressed. Supported compression types are:
CompressionType.LZ4
CompressionType.ZLIB
compressionType
- public CompressionType getCompressionType()
public ProducerConfiguration setMessageRouter(MessageRouter messageRouter)
messageRouter
- @Deprecated public MessageRouter getMessageRouter(int numPartitions)
MessageRouter.choosePartition(Message, TopicMetadata)
.setMessageRouter(MessageRouter)
.MessageRouter
public MessageRouter getMessageRouter()
setMessageRouter(MessageRouter)
.setMessageRouter(MessageRouter)
.public boolean getBatchingEnabled()
public ProducerConfiguration setBatchingEnabled(boolean batchMessagesEnabled)
setBatchingMaxPublishDelay(long, TimeUnit)
public CryptoKeyReader getCryptoKeyReader()
public ProducerConfiguration setCryptoKeyReader(CryptoKeyReader cryptoKeyReader)
CryptoKeyReader
cryptoKeyReader
- CryptoKeyReader objectpublic Set<String> getEncryptionKeys()
public boolean isEncryptionEnabled()
public void addEncryptionKey(String key)
public void removeEncryptionKey(String key)
public void setCryptoFailureAction(ProducerCryptoFailureAction action)
action
- The producer actionpublic ProducerCryptoFailureAction getCryptoFailureAction()
public long getBatchingMaxPublishDelayMs()
setBatchingMaxPublishDelay(long, TimeUnit)
public ProducerConfiguration setBatchingMaxPublishDelay(long batchDelay, TimeUnit timeUnit)
batchDelay
- the batch delaytimeUnit
- the time unit of the batchDelay
threshold is reached; all messages will be published as a single
batch message. The consumer will be delivered individual messages in the batch in the same order they were
enqueued
public int getBatchingMaxMessages()
public ProducerConfiguration setBatchingMaxMessages(int batchMessagesMaxMessagesPerBatch)
batchMessagesMaxMessagesPerBatch
- maximum number of messages in a batchAll messages in batch will be published as
a single batch message. The consumer will be delivered individual messages in the batch in the same order
they were enqueued
public Optional<Long> getInitialSequenceId()
public ProducerConfiguration setInitialSequenceId(long initialSequenceId)
First message will be using (initialSequenceId + 1) as its sequence id and subsequent messages will be assigned incremental sequence ids, if not otherwise specified.
initialSequenceId
- public ProducerConfiguration setProperty(String key, String value)
key
- value
- public ProducerConfiguration setProperties(Map<String,String> properties)
properties
- public Map<String,String> getProperties()
public ProducerConfigurationData getProducerConfigurationData()