Class ProducerConfiguration

java.lang.Object
org.apache.pulsar.client.api.ProducerConfiguration
All Implemented Interfaces:
Serializable

@Deprecated public class ProducerConfiguration extends Object implements Serializable
Deprecated.
use PulsarClient#newProducer() to construct and configure a Producer instance
Producer's configuration.
See Also:
  • Constructor Details

    • ProducerConfiguration

      public ProducerConfiguration()
      Deprecated.
  • Method Details

    • getProducerName

      public String getProducerName()
      Deprecated.
      Returns:
      the configured custom producer name or null if no custom name was specified
      Since:
      1.20.0
    • setProducerName

      public void setProducerName(String producerName)
      Deprecated.
      Specify a name for the producer

      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.

      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

      public ProducerConfiguration setSendTimeout(int sendTimeout, TimeUnit unit)
      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 timeout
      unit - the time unit of the sendTimeout
    • getMaxPendingMessages

      public int getMaxPendingMessages()
      Deprecated.
      Returns:
      the maximum number of messages allowed in the outstanding messages queue for the producer
    • setMaxPendingMessages

      public ProducerConfiguration setMaxPendingMessages(int maxPendingMessages)
      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[]) and Producer.sendAsync(byte[]) will fail unless blockIfQueueFull is set to true. Use setBlockIfQueueFull(boolean) to change the blocking behavior.

      Parameters:
      maxPendingMessages -
      Returns:
    • getHashingScheme

      public ProducerConfiguration.HashingScheme getHashingScheme()
      Deprecated.
    • setHashingScheme

      public ProducerConfiguration setHashingScheme(ProducerConfiguration.HashingScheme hashingScheme)
      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 partitions

      This 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[]) and Producer.sendAsync(byte[]) operations when the pending queue is full
    • setBlockIfQueueFull

      public ProducerConfiguration setBlockIfQueueFull(boolean blockIfQueueFull)
      Deprecated.
      Set whether the Producer.send(byte[]) and Producer.sendAsync(byte[]) 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.

      Parameters:
      blockIfQueueFull - whether to block Producer.send(byte[]) and Producer.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

      public ProducerConfiguration.MessageRoutingMode 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.LZ4
      • CompressionType.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 public org.apache.pulsar.client.api.MessageRouter getMessageRouter(int numPartitions)
      Deprecated.
      since 1.22.0-incubating. numPartitions is already passed as parameter in MessageRouter.choosePartition(Message, TopicMetadata).
      Get the message router set by setMessageRouter(MessageRouter).
      Returns:
      message router.
      See Also:
      • MessageRouter
    • getMessageRouter

      public org.apache.pulsar.client.api.MessageRouter getMessageRouter()
      Deprecated.
      Get the message router set by setMessageRouter(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

      public ProducerConfiguration setBatchingEnabled(boolean batchMessagesEnabled)
      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 a CryptoKeyReader.
      Parameters:
      cryptoKeyReader - CryptoKeyReader object
    • getEncryptionKeys

      public Set<String> getEncryptionKeys()
      Deprecated.
      Returns:
      encryptionKeys
    • isEncryptionEnabled

      public boolean isEncryptionEnabled()
      Deprecated.
      Returns true if encryption keys are added.
    • addEncryptionKey

      public void addEncryptionKey(String key)
      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

      public void removeEncryptionKey(String key)
      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

      public ProducerConfiguration 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. If set to a non zero value, messages will be queued until this time interval or until
      Parameters:
      batchDelay - the batch delay
      timeUnit - the time unit of the batchDelay
      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

      public ProducerConfiguration setBatchingMaxMessages(int batchMessagesMaxMessagesPerBatch)
      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

      public Optional<Long> getInitialSequenceId()
      Deprecated.
    • setInitialSequenceId

      public ProducerConfiguration setInitialSequenceId(long initialSequenceId)
      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

      public ProducerConfiguration setProperty(String key, String value)
      Deprecated.
      Set a name/value property with this producer.
      Parameters:
      key -
      value -
      Returns:
    • setProperties

      public ProducerConfiguration setProperties(Map<String,String> properties)
      Deprecated.
      Add all the properties in the provided map.
      Parameters:
      properties -
      Returns:
    • getProperties

      public Map<String,String> getProperties()
      Deprecated.
    • getProducerConfigurationData

      public org.apache.pulsar.client.impl.conf.ProducerConfigurationData getProducerConfigurationData()
      Deprecated.