Class Producer

java.lang.Object
org.apache.pulsar.broker.service.Producer

public class Producer extends Object
Represents a currently connected producer.
  • Constructor Details

    • Producer

      public Producer(Topic topic, TransportCnx cnx, long producerId, String producerName, String appId, boolean isEncrypted, Map<String,String> metadata, org.apache.pulsar.common.protocol.schema.SchemaVersion schemaVersion, long epoch, boolean userProvidedProducerName, org.apache.pulsar.common.api.proto.ProducerAccessMode accessMode, Optional<Long> topicEpoch, boolean supportsPartialProducer)
  • Method Details

    • isSuccessorTo

      public boolean isSuccessorTo(Producer other)
      Method to determine if this producer can replace another producer.
      Parameters:
      other - - producer to compare to this one
      Returns:
      true if this producer is a subsequent instantiation of the same logical producer. Otherwise, false.
    • publishMessage

      public void publishMessage(long producerId, long sequenceId, io.netty.buffer.ByteBuf headersAndPayload, int batchSize, boolean isChunked, boolean isMarker, Position position)
    • publishMessage

      public void publishMessage(long producerId, long lowestSequenceId, long highestSequenceId, io.netty.buffer.ByteBuf headersAndPayload, int batchSize, boolean isChunked, boolean isMarker, Position position)
    • checkAndStartPublish

      public boolean checkAndStartPublish(long producerId, long sequenceId, io.netty.buffer.ByteBuf headersAndPayload, int batchSize, Position position)
    • recordMessageDrop

      public void recordMessageDrop(int batchSize)
    • getLastSequenceId

      public long getLastSequenceId()
      Return the sequence id of.
      Returns:
      the sequence id
    • getCnx

      public TransportCnx getCnx()
    • getTopic

      public Topic getTopic()
    • getProducerName

      public String getProducerName()
    • getProducerId

      public long getProducerId()
    • getMetadata

      public Map<String,String> getMetadata()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • close

      public CompletableFuture<Void> close(boolean removeFromTopic)
      Close the producer immediately if: a. the connection is dropped b. it's a graceful close and no pending publish acks are left else wait for pending publish acks
      Returns:
      completable future indicate completion of close
    • closeNow

      public void closeNow(boolean removeFromTopic)
    • disconnect

      public CompletableFuture<Void> disconnect()
    • disconnect

      public CompletableFuture<Void> disconnect(Optional<BrokerLookupData> assignedBrokerLookupData)
      It closes the producer from server-side and sends command to client to disconnect producer from existing connection without closing that connection.
      Returns:
      Completable future indicating completion of producer close
    • topicMigrated

      public void topicMigrated(Optional<org.apache.pulsar.common.policies.data.ClusterPolicies.ClusterUrl> clusterUrl)
    • updateRates

      public void updateRates()
    • isRemote

      public boolean isRemote()
    • getRemoteCluster

      public String getRemoteCluster()
    • getStats

      public org.apache.pulsar.common.policies.data.stats.PublisherStatsImpl getStats()
    • isNonPersistentTopic

      public boolean isNonPersistentTopic()
    • getEpoch

      public long getEpoch()
    • isUserProvidedProducerName

      public boolean isUserProvidedProducerName()
    • checkPermissionsAsync

      public CompletableFuture<Void> checkPermissionsAsync()
    • checkEncryption

      public void checkEncryption()
    • publishTxnMessage

      public void publishTxnMessage(org.apache.pulsar.client.api.transaction.TxnID txnID, long producerId, long sequenceId, long highSequenceId, io.netty.buffer.ByteBuf headersAndPayload, int batchSize, boolean isChunked, boolean isMarker)
    • getSchemaVersion

      public org.apache.pulsar.common.protocol.schema.SchemaVersion getSchemaVersion()
    • getAccessMode

      public org.apache.pulsar.common.api.proto.ProducerAccessMode getAccessMode()
    • getTopicEpoch

      public Optional<Long> getTopicEpoch()
    • getClientAddress

      public String getClientAddress()
    • isDisconnecting

      public boolean isDisconnecting()
    • incrementThrottleCount

      public void incrementThrottleCount()
      This method increments a counter that is used to control the throttling of a connection. The connection's read operations are paused when the counter's value is greater than 0, indicating that throttling is in effect. It's important to note that after calling this method, it is the caller's responsibility to ensure that the counter is decremented by calling the decrementThrottleCount() method when throttling is no longer needed on the connection.
    • decrementThrottleCount

      public void decrementThrottleCount()
      This method decrements a counter that is used to control the throttling of a connection. The connection's read operations are resumed when the counter's value is 0, indicating that throttling is no longer in effect. It's important to note that before calling this method, the caller should have previously incremented the counter by calling the incrementThrottleCount() method when throttling was needed on the connection.
    • getOpenTelemetryAttributes

      public io.opentelemetry.api.common.Attributes getOpenTelemetryAttributes()