Package org.apache.pulsar.broker.service
Class Producer
java.lang.Object
org.apache.pulsar.broker.service.Producer
Represents a currently connected producer.
-
Constructor Summary
ConstructorsConstructorDescriptionProducer(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 Summary
Modifier and TypeMethodDescriptionbooleancheckAndStartPublish(long producerId, long sequenceId, io.netty.buffer.ByteBuf headersAndPayload, int batchSize, Position position) voidclose(boolean removeFromTopic) Close the producer immediately if: a.voidcloseNow(boolean removeFromTopic) voidThis method decrements a counter that is used to control the throttling of a connection.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.org.apache.pulsar.common.api.proto.ProducerAccessModegetCnx()longgetEpoch()longReturn the sequence id of.io.opentelemetry.api.common.Attributeslongorg.apache.pulsar.common.protocol.schema.SchemaVersionorg.apache.pulsar.common.policies.data.stats.PublisherStatsImplgetStats()getTopic()voidThis method increments a counter that is used to control the throttling of a connection.booleanbooleanbooleanisRemote()booleanisSuccessorTo(Producer other) Method to determine if this producer can replace another producer.booleanvoidpublishMessage(long producerId, long lowestSequenceId, long highestSequenceId, io.netty.buffer.ByteBuf headersAndPayload, int batchSize, boolean isChunked, boolean isMarker, Position position) voidpublishMessage(long producerId, long sequenceId, io.netty.buffer.ByteBuf headersAndPayload, int batchSize, boolean isChunked, boolean isMarker, Position position) voidpublishTxnMessage(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) voidrecordMessageDrop(int batchSize) voidtopicMigrated(Optional<org.apache.pulsar.common.policies.data.ClusterPolicies.ClusterUrl> clusterUrl) toString()void
-
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
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
-
getTopic
-
getProducerName
-
getProducerId
public long getProducerId() -
getMetadata
-
toString
-
close
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
-
disconnect
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
-
getStats
public org.apache.pulsar.common.policies.data.stats.PublisherStatsImpl getStats() -
isNonPersistentTopic
public boolean isNonPersistentTopic() -
getEpoch
public long getEpoch() -
isUserProvidedProducerName
public boolean isUserProvidedProducerName() -
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
-
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 thedecrementThrottleCount()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 theincrementThrottleCount()method when throttling was needed on the connection. -
getOpenTelemetryAttributes
public io.opentelemetry.api.common.Attributes getOpenTelemetryAttributes()
-