PubsubClient class

Constructors

PubsubClient({Logger? logger, String host = 'pubsub.googleapis.com', int port = 443, List<String> scopes = const ['https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/datastore', kScope], required String serviceAccountJson})

Properties

hashCode int
The hash code for this object.
no setterinherited
publisherClient → PublisherClient
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
subscriberClient → SubscriberClient
no setter

Methods

acknowledge({required Iterable<String> ackIds, int retries = 5, required String subscription}) Future<void>
Acknowledges the messages associated with the ackIds. The Pub/Sub system can remove the relevant messages from the subscription. Acknowledging a message whose ack deadline has expired may succeed, but such a message may be redelivered later. Acknowledging a message more than once will not result in an error.
createSnapshot({required Map<String, String> labels, int retries = 5, required String snapshot, required String subscription}) Future<Snapshot>
Creates a snapshot from the requested subscription. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot. If the snapshot already exists, returns ALREADY_EXISTS. If the requested subscription doesn't exist, returns NOT_FOUND. If the backlog in the subscription is too old -- and the resulting snapshot would expire in less than 1 hour -- then FAILED_PRECONDITION is returned. See also the Snapshot.expire_time field. If the name is not provided in the request, the server will assign a random name for this snapshot on the same project as the subscription, conforming to the resource name format. The generated name is populated in the returned Snapshot object. Note that for REST API requests, you must specify a name in the request.
createSubscription({int? ackDeadlineSeconds, DeadLetterPolicy? deadLetterPolicy, bool? enableMessageOrdering, ExpirationPolicy? expirationPolicy, String? filter, Map<String, String>? labels, Duration? messageRetentionDuration, PushConfig? pushConfig, bool? retainAckedMessages, int retries = 5, RetryPolicy? retryPolicy, String? subscription, required String topic, Duration? topicMessageRetentionDuration}) Future<Subscription>
Creates a subscription to a given topic. See the resource name rules. If the subscription already exists, returns ALREADY_EXISTS. If the corresponding topic doesn't exist, returns NOT_FOUND.
createTopic({Map<String, String>? labels, MessageStoragePolicy? messageStoragePolicy, String? kmsKeyName, int retries = 5, SchemaSettings? schemaSettings, Duration? messageRetentionDuration, required String topic}) Future<Topic>
Creates a topic with the given topic. The topic can either be the simple name of the topic or it may be the fully quantified name in the projects/{project}/topics/{topic} format.
deleteSnapshot({int retries = 5, required String snapshot}) Future<void>
Removes an existing snapshot. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot. When the snapshot is deleted, all messages retained in the snapshot are immediately dropped. After a snapshot is deleted, a new one may be created with the same name, but the new one has no association with the old snapshot or its subscription, unless the same subscription is specified.
deleteSubscription({int retries = 5, required String subscription}) Future<void>
Deletes an existing subscription. All messages retained in the subscription are immediately dropped. Calls to Pull after deletion will return NOT_FOUND. After a subscription is deleted, a new one may be created with the same name, but the new one has no association with the old subscription or its topic unless the same topic is specified.
deleteTopic({int retries = 5, required String topic}) Future<void>
Deletes the topic. The topic can either be the simple name of the topic or it may be the fully quantified name in the projects/{project}/topics/{topic} format.
detachSubscription({int retries = 5, required String subscription}) Future<DetachSubscriptionResponse>
Detaches a subscription from this topic. All messages retained in the subscription are dropped. Subsequent Pull and StreamingPull requests will return FAILED_PRECONDITION. If the subscription is a push subscription, pushes to the endpoint will stop.
dispose() Future<void>
Disposes the client. A disposed client cannot have other functions called unless it is re-initialized via the initialize function.
getSnapshot({int retries = 5, required String snapshot}) Future<Snapshot>
Gets the configuration details of a snapshot. Snapshots are used in seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.
getSubscription({int retries = 5, required String subscription}) Future<Subscription>
Gets the configuration details of a subscription.
getTopic({int retries = 5, required String topic}) Future<Topic>
Gets the configuration of a topic. The name of the topic can be the simple name or it can be the fully quantified format: projects/{project}/topics/{topic}.
initialize() Future<void>
Initializes the client and prepares it for for use. A client must be initialized before any of the other attributes or functions may be called.
listSnapshots({int? pageSize, String? pageToken, String? project, int retries = 5}) Future<ListSnapshotsResponse>
Lists the existing snapshots. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.
listSubscriptions({int? pageSize, String? pageToken, String? project, int retries = 5}) Future<ListSubscriptionsResponse>
Lists matching subscriptions.
listTopics({int? pageSize, String? pageToken, String? project, int retries = 5}) Future<ListTopicsResponse>
Lists matching topics. If set, the project can be either just the project id or it can be the fully quantified format: projects/{project}.
listTopicSnapshots({int? pageSize, String? pageToken, int retries = 5, required String topic}) Future<ListTopicSnapshotsResponse>
Lists the names of the snapshots on this topic. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.
listTopicSubscriptions({int? pageSize, String? pageToken, int retries = 5, required String topic}) Future<ListTopicSubscriptionsResponse>
Lists the names of the attached subscriptions on this topic.
modifyAckDeadline({required int ackDeadlineSeconds, required Iterable<String> ackIds, int retries = 5, required String subscription}) Future<void>
Modifies the ack deadline for a specific message. This method is useful to indicate that more time is needed to process a message by the subscriber, or to make the message available for redelivery if the processing was interrupted. Note that this does not modify the subscription-level ackDeadlineSeconds used for subsequent messages.
modifyPushConfig({required PushConfig pushConfig, int retries = 5, required String subscription}) Future<Empty>
Modifies the PushConfig for a specified subscription.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
publish({required Iterable<PubsubMessage> messages, int retries = 5, required String topic}) Future<PublishResponse>
Adds one or more messages to the topic. Returns NOT_FOUND if the topic does not exist.
pull({required int maxMessages, int retries = 5, required String subscription}) Future<List<ReceivedMessage>>
Pulls messages from the server. The server may return UNAVAILABLE if there are too many concurrent pull requests pending for the given subscription.
seek({required int maxMessages, int retries = 5, required String subscription}) Future<SeekResponse>
Seeks an existing subscription to a point in time or to a given snapshot, whichever is provided in the request. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot. Note that both the subscription and the snapshot must be on the same topic.
streamingPull({Duration connectionTtl = const Duration(minutes: 5), void onClosed()?, int retries = 5, required Stream<StreamingPullRequest> stream, required StreamingPullRequest subscribeRequest}) Future<Stream<StreamingPullResponse>>
Establishes a stream with the server, which sends messages down to the client. The client streams acknowledgements and ack deadline modifications back to the server. The server will close the stream and return the status on any error. The server may close the stream with status UNAVAILABLE to reassign server-side resources, in which case, the client should re-establish the stream. Flow control can be achieved by configuring the underlying RPC channel.
toString() String
A string representation of this object.
inherited
updateSnapshot({int retries = 5, required Snapshot snapshot, required List<SnapshotField> updateMask}) Future<Snapshot>
Updates an existing snapshot. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.
updateSubscription({int retries = 5, required Subscription subscription, required Iterable<SubscriptionField> updateMask}) Future<Subscription>
Updates an existing subscription. Note that certain properties of a subscription, such as its topic, are not modifiable.
updateTopic({int retries = 5, required Topic topic, required Iterable<TopicField> updateMask}) Future<Topic>
Updates an existing topic. Note that certain properties of a topic are not modifiable.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

kScope → const String