Class ProducerConfiguration
- All Implemented Interfaces:
Serializable
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDeprecated.static enumDeprecated. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEncryptionKey(String key) Deprecated.Add public encryption key, used by producer to encrypt the data key.booleanDeprecated.Return the flag whether automatic message batching is enabled or not.intDeprecated.longDeprecated.booleanDeprecated.org.apache.pulsar.client.api.CompressionTypeDeprecated.org.apache.pulsar.client.api.ProducerCryptoFailureActionDeprecated.org.apache.pulsar.client.api.CryptoKeyReaderDeprecated.Deprecated.Deprecated.Deprecated.intDeprecated.intDeprecated.org.apache.pulsar.client.api.MessageRouterDeprecated.Get the message router set bysetMessageRouter(MessageRouter).org.apache.pulsar.client.api.MessageRoutergetMessageRouter(int numPartitions) Deprecated.since 1.22.0-incubating.Deprecated.Get the message routing mode for the partitioned producer.org.apache.pulsar.client.impl.conf.ProducerConfigurationDataDeprecated.Deprecated.Deprecated.longDeprecated.booleanDeprecated.Returns true if encryption keys are added.voidDeprecated.setBatchingEnabled(boolean batchMessagesEnabled) Deprecated.Control whether automatic batching of messages is enabled for the producer.setBatchingMaxMessages(int batchMessagesMaxMessagesPerBatch) Deprecated.Set the maximum number of messages permitted in a batch.setBatchingMaxPublishDelay(long batchDelay, TimeUnit timeUnit) Deprecated.Set the time period within which the messages sent will be batched default: 1ms if batch messages are enabled.setBlockIfQueueFull(boolean blockIfQueueFull) Deprecated.Set whether theProducer.send(byte[])andProducer.sendAsync(byte[])operations should block when the outgoing message queue is full.setCompressionType(org.apache.pulsar.client.api.CompressionType compressionType) Deprecated.Set the compression type for the producer.voidsetCryptoFailureAction(org.apache.pulsar.client.api.ProducerCryptoFailureAction action) Deprecated.Sets the ProducerCryptoFailureAction to the value specified.setCryptoKeyReader(org.apache.pulsar.client.api.CryptoKeyReader cryptoKeyReader) Deprecated.Sets aCryptoKeyReader.setHashingScheme(ProducerConfiguration.HashingScheme hashingScheme) Deprecated.setInitialSequenceId(long initialSequenceId) Deprecated.Set the baseline for the sequence ids for messages published by the producer.setMaxPendingMessages(int maxPendingMessages) Deprecated.Set the max size of the queue holding the messages pending to receive an acknowledgment from the broker.voidsetMaxPendingMessagesAcrossPartitions(int maxPendingMessagesAcrossPartitions) Deprecated.Set the number of max pending messages across all the partitionssetMessageRouter(org.apache.pulsar.client.api.MessageRouter messageRouter) Deprecated.Set a custom message routing policy by passing an implementation of MessageRouter.setMessageRoutingMode(ProducerConfiguration.MessageRoutingMode messageRouteMode) Deprecated.Set the message routing mode for the partitioned producer.voidsetProducerName(String producerName) Deprecated.Specify a name for the producersetProperties(Map<String, String> properties) Deprecated.Add all the properties in the provided map.setProperty(String key, String value) Deprecated.Set a name/value property with this producer.setSendTimeout(int sendTimeout, TimeUnit unit) Deprecated.Set the send timeout (default: 30 seconds)
-
Constructor Details
-
ProducerConfiguration
public ProducerConfiguration()Deprecated.
-
-
Method Details
-
getProducerName
Deprecated.- Returns:
- the configured custom producer name or null if no custom name was specified
- Since:
- 1.20.0
-
setProducerName
Deprecated.Specify a name for the producerIf 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 withPulsarClientException.ProducerBusyException.- Parameters:
producerName- the custom name to use for the producer- Since:
- 1.20.0
-
getSendTimeoutMs
public long getSendTimeoutMs()Deprecated.- Returns:
- the message send timeout in ms
-
setSendTimeout
Deprecated.Set the send timeout (default: 30 seconds)If a message is not acknowledged by the server before the sendTimeout expires, an error will be reported.
- Parameters:
sendTimeout- the send timeoutunit- the time unit of thesendTimeout
-
getMaxPendingMessages
public int getMaxPendingMessages()Deprecated.- Returns:
- the maximum number of messages allowed in the outstanding messages queue for the producer
-
setMaxPendingMessages
Deprecated.Set the max size of the queue holding the messages pending to receive an acknowledgment from the broker.When the queue is full, by default, all calls to
Producer.send(byte[])andProducer.sendAsync(byte[])will fail unless blockIfQueueFull is set to true. UsesetBlockIfQueueFull(boolean)to change the blocking behavior.- Parameters:
maxPendingMessages-- Returns:
-
getHashingScheme
Deprecated. -
setHashingScheme
Deprecated. -
getMaxPendingMessagesAcrossPartitions
public int getMaxPendingMessagesAcrossPartitions()Deprecated.- Returns:
- the maximum number of pending messages allowed across all the partitions
-
setMaxPendingMessagesAcrossPartitions
public void setMaxPendingMessagesAcrossPartitions(int maxPendingMessagesAcrossPartitions) Deprecated.Set the number of max pending messages across all the partitionsThis setting will be used to lower the max pending messages for each partition (
setMaxPendingMessages(int)), if the total exceeds the configured value.- Parameters:
maxPendingMessagesAcrossPartitions-
-
getBlockIfQueueFull
public boolean getBlockIfQueueFull()Deprecated.- Returns:
- whether the producer will block
Producer.send(byte[])andProducer.sendAsync(byte[])operations when the pending queue is full
-
setBlockIfQueueFull
Deprecated.Set whether theProducer.send(byte[])andProducer.sendAsync(byte[])operations should block when the outgoing message queue is full.Default is
false. If set tofalse, send operations will immediately fail withPulsarClientException.ProducerQueueIsFullErrorwhen there is no space left in pending queue.- Parameters:
blockIfQueueFull- whether to blockProducer.send(byte[])andProducer.sendAsync(byte[])operations on queue full- Returns:
-
setMessageRoutingMode
public ProducerConfiguration setMessageRoutingMode(ProducerConfiguration.MessageRoutingMode messageRouteMode) Deprecated.Set the message routing mode for the partitioned producer.- Parameters:
messageRouteMode- message routing mode.- Returns:
- producer configuration
- See Also:
-
getMessageRoutingMode
Deprecated.Get the message routing mode for the partitioned producer.- Returns:
- message routing mode, default is round-robin routing.
- See Also:
-
setCompressionType
public ProducerConfiguration setCompressionType(org.apache.pulsar.client.api.CompressionType compressionType) Deprecated.Set the compression type for the producer.By default, message payloads are not compressed. Supported compression types are:
CompressionType.LZ4CompressionType.ZLIB
- Parameters:
compressionType-- Returns:
- Since:
- 1.0.28
Make sure all the consumer applications have been updated to use this client version, before starting to compress messages.
-
getCompressionType
public org.apache.pulsar.client.api.CompressionType getCompressionType()Deprecated.- Returns:
- the configured compression type for this producer
-
setMessageRouter
public ProducerConfiguration setMessageRouter(org.apache.pulsar.client.api.MessageRouter messageRouter) Deprecated.Set a custom message routing policy by passing an implementation of MessageRouter.- Parameters:
messageRouter-
-
getMessageRouter
Deprecated.since 1.22.0-incubating. numPartitions is already passed as parameter inMessageRouter.choosePartition(Message, TopicMetadata).Get the message router set bysetMessageRouter(MessageRouter).- Returns:
- message router.
- See Also:
-
MessageRouter
-
getMessageRouter
public org.apache.pulsar.client.api.MessageRouter getMessageRouter()Deprecated.Get the message router set bysetMessageRouter(MessageRouter).- Returns:
- message router set by
setMessageRouter(MessageRouter).
-
getBatchingEnabled
public boolean getBatchingEnabled()Deprecated.Return the flag whether automatic message batching is enabled or not.- Returns:
- true if batch messages are enabled. otherwise false.
- Since:
- 2.0.0
It is enabled by default.
-
setBatchingEnabled
Deprecated.Control whether automatic batching of messages is enabled for the producer. default: false [No batching] When batching is enabled, multiple calls to Producer.sendAsync can result in a single batch to be sent to the broker, leading to better throughput, especially when publishing small messages. If compression is enabled, messages will be compressed at the batch level, leading to a much better compression ratio for similar headers or contents. When enabled default batch delay is set to 1 ms and default batch size is 1000 messages- Since:
- 1.0.36
Make sure all the consumer applications have been updated to use this client version, before starting to batch messages. - See Also:
-
getCryptoKeyReader
public org.apache.pulsar.client.api.CryptoKeyReader getCryptoKeyReader()Deprecated.- Returns:
- the CryptoKeyReader
-
setCryptoKeyReader
public ProducerConfiguration setCryptoKeyReader(org.apache.pulsar.client.api.CryptoKeyReader cryptoKeyReader) Deprecated.Sets aCryptoKeyReader.- Parameters:
cryptoKeyReader- CryptoKeyReader object
-
getEncryptionKeys
Deprecated.- Returns:
- encryptionKeys
-
isEncryptionEnabled
public boolean isEncryptionEnabled()Deprecated.Returns true if encryption keys are added. -
addEncryptionKey
Deprecated.Add public encryption key, used by producer to encrypt the data key. At the time of producer creation, Pulsar client checks if there are keys added to encryptionKeys. If keys are found, a callback getKey(String keyName) is invoked against each key to load the values of the key. Application should implement this callback to return the key in pkcs8 format. If compression is enabled, message is encrypted after compression. If batch messaging is enabled, the batched message is encrypted. -
removeEncryptionKey
Deprecated. -
setCryptoFailureAction
public void setCryptoFailureAction(org.apache.pulsar.client.api.ProducerCryptoFailureAction action) Deprecated.Sets the ProducerCryptoFailureAction to the value specified.- Parameters:
action- The producer action
-
getCryptoFailureAction
public org.apache.pulsar.client.api.ProducerCryptoFailureAction getCryptoFailureAction()Deprecated.- Returns:
- The ProducerCryptoFailureAction
-
getBatchingMaxPublishDelayMs
public long getBatchingMaxPublishDelayMs()Deprecated.- Returns:
- the batch time period in ms.
- See Also:
-
setBatchingMaxPublishDelay
Deprecated.Set the time period within which the messages sent will be batched default: 1ms if batch messages are enabled. If set to a non zero value, messages will be queued until this time interval or until- Parameters:
batchDelay- the batch delaytimeUnit- the time unit of thebatchDelay- Returns:
- Since:
- 1.0.36
Make sure all the consumer applications have been updated to use this client version, before starting to batch messages. - See Also:
-
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
-
getBatchingMaxMessages
public int getBatchingMaxMessages()Deprecated.- Returns:
- the maximum number of messages permitted in a batch.
-
setBatchingMaxMessages
Deprecated.Set the maximum number of messages permitted in a batch. default: 1000 If set to a value greater than 1, messages will be queued until this threshold is reached or batch interval has elapsed- Parameters:
batchMessagesMaxMessagesPerBatch- maximum number of messages in a batch- Returns:
- See Also:
-
getInitialSequenceId
Deprecated. -
setInitialSequenceId
Deprecated.Set the baseline for the sequence ids for messages published by the producer.First message will be using (initialSequenceId + 1) as its sequence id and subsequent messages will be assigned incremental sequence ids, if not otherwise specified.
- Parameters:
initialSequenceId-- Returns:
-
setProperty
Deprecated.Set a name/value property with this producer.- Parameters:
key-value-- Returns:
-
setProperties
Deprecated.Add all the properties in the provided map.- Parameters:
properties-- Returns:
-
getProperties
Deprecated. -
getProducerConfigurationData
public org.apache.pulsar.client.impl.conf.ProducerConfigurationData getProducerConfigurationData()Deprecated.
-
PulsarClient#newProducer()to construct and configure aProducerinstance