public class PubSubAdmin extends Object implements AutoCloseable
Modifier and Type | Field and Description |
---|---|
protected static int |
MAX_ACK_DEADLINE_SECONDS |
protected static int |
MIN_ACK_DEADLINE_SECONDS |
Constructor and Description |
---|
PubSubAdmin(GcpProjectIdProvider projectIdProvider,
com.google.api.gax.core.CredentialsProvider credentialsProvider)
This constructor instantiates TopicAdminClient and SubscriptionAdminClient with all their
defaults and the provided credentials provider.
|
PubSubAdmin(GcpProjectIdProvider projectIdProvider,
TopicAdminClient topicAdminClient,
SubscriptionAdminClient subscriptionAdminClient) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
com.google.pubsub.v1.Subscription |
createSubscription(String subscriptionName,
String topicName)
Create a new subscription on Google Cloud Pub/Sub.
|
com.google.pubsub.v1.Subscription |
createSubscription(String subscriptionName,
String topicName,
Integer ackDeadline)
Create a new subscription on Google Cloud Pub/Sub.
|
com.google.pubsub.v1.Subscription |
createSubscription(String subscriptionName,
String topicName,
Integer ackDeadline,
String pushEndpoint)
Create a new subscription on Google Cloud Pub/Sub.
|
com.google.pubsub.v1.Subscription |
createSubscription(String subscriptionName,
String topicName,
String pushEndpoint)
Create a new subscription on Google Cloud Pub/Sub.
|
com.google.pubsub.v1.Subscription |
createSubscription(com.google.pubsub.v1.Subscription.Builder builder)
Create a new subscription on Google Cloud Pub/Sub.
|
com.google.pubsub.v1.Topic |
createTopic(String topicName)
Create a new topic on Google Cloud Pub/Sub.
|
void |
deleteSubscription(String subscriptionName)
Delete a subscription from Google Cloud Pub/Sub.
|
void |
deleteTopic(String topicName)
Delete a topic from Google Cloud Pub/Sub.
|
int |
getDefaultAckDeadline()
Get the default ack deadline.
|
com.google.pubsub.v1.Subscription |
getSubscription(String subscriptionName)
Get the configuration of a Google Cloud Pub/Sub subscription.
|
com.google.pubsub.v1.Topic |
getTopic(String topicName)
Get the configuration of a Google Cloud Pub/Sub topic.
|
List<com.google.pubsub.v1.Subscription> |
listSubscriptions()
Return every subscription in a project.
|
List<com.google.pubsub.v1.Topic> |
listTopics()
Return every topic in a project.
|
void |
setDefaultAckDeadline(int defaultAckDeadline)
Set the default acknowledgement deadline value.
|
protected static final int MIN_ACK_DEADLINE_SECONDS
protected static final int MAX_ACK_DEADLINE_SECONDS
public PubSubAdmin(GcpProjectIdProvider projectIdProvider, com.google.api.gax.core.CredentialsProvider credentialsProvider)
projectIdProvider
- the project id provider to usecredentialsProvider
- the credentials provider to usePubSubException
- thrown when there are errors in contacting Google Cloud Pub/Subpublic PubSubAdmin(GcpProjectIdProvider projectIdProvider, TopicAdminClient topicAdminClient, SubscriptionAdminClient subscriptionAdminClient)
public com.google.pubsub.v1.Topic createTopic(String topicName)
topicName
- the name for the new topic within the current project, or the
fully-qualified topic name in the projects/<project_name>/topics/<topic_name>
formatpublic com.google.pubsub.v1.Topic getTopic(String topicName)
topicName
- canonical topic name, e.g., "topicName", or the fully-qualified topic name in the
projects/<project_name>/topics/<topic_name>
formatnull
if topic doesn't existpublic void deleteTopic(String topicName)
topicName
- canonical topic name, e.g., "topicName", or the fully-qualified topic
name in the projects/<project_name>/topics/<topic_name>
formatpublic List<com.google.pubsub.v1.Topic> listTopics()
If there are multiple pages, they will all be merged into the same result.
public com.google.pubsub.v1.Subscription createSubscription(String subscriptionName, String topicName)
subscriptionName
- canonical subscription name, e.g., "subscriptionName", or the fully-qualified
subscription name in the projects/<project_name>/subscriptions/<subscription_name>
formattopicName
- canonical topic name, e.g., "topicName", or the fully-qualified topic name in the
projects/<project_name>/topics/<topic_name>
formatpublic com.google.pubsub.v1.Subscription createSubscription(String subscriptionName, String topicName, Integer ackDeadline)
subscriptionName
- canonical subscription name, e.g., "subscriptionName", or the fully-qualified
subscription name in the projects/<project_name>/subscriptions/<subscription_name>
formattopicName
- canonical topic name, e.g., "topicName", or the fully-qualified topic name in the
projects/<project_name>/topics/<topic_name>
formatackDeadline
- deadline in seconds before a message is resent, must be between 10
and 600 seconds. If not provided, set to default of 10 secondspublic com.google.pubsub.v1.Subscription createSubscription(String subscriptionName, String topicName, String pushEndpoint)
subscriptionName
- canonical subscription name, e.g., "subscriptionName", or the fully-qualified
subscription name in the projects/<project_name>/subscriptions/<subscription_name>
formattopicName
- canonical topic name, e.g., "topicName", or the fully-qualified topic name in the
projects/<project_name>/topics/<topic_name>
formatpushEndpoint
- the URL of the service receiving the push messages. If not provided, uses
message pulling by defaultpublic com.google.pubsub.v1.Subscription createSubscription(String subscriptionName, String topicName, Integer ackDeadline, String pushEndpoint)
subscriptionName
- canonical subscription name, e.g., "subscriptionName", or the fully-qualified
subscription name in the projects/<project_name>/subscriptions/<subscription_name>
formattopicName
- canonical topic name, e.g., "topicName", or the fully-qualified topic name in the
projects/<project_name>/topics/<topic_name>
formatackDeadline
- deadline in seconds before a message is resent, must be between 10
and 600 seconds. If not provided, set to default of 10 secondspushEndpoint
- the URL of the service receiving the push messages. If not
provided, uses message pulling by defaultpublic com.google.pubsub.v1.Subscription createSubscription(com.google.pubsub.v1.Subscription.Builder builder)
builder
- a Subscription.Builder straight from the client API library that exposes all available knobs and
levers. The name and topic fields will be expanded to fully qualified names (i.e.
"projects/my-project/topic/my-topic") if they are not already.public com.google.pubsub.v1.Subscription getSubscription(String subscriptionName)
subscriptionName
- canonical subscription name, e.g., "subscriptionName", or the fully-qualified
subscription name in the projects/<project_name>/subscriptions/<subscription_name>
formatnull
if subscription doesn't existpublic void deleteSubscription(String subscriptionName)
subscriptionName
- canonical subscription name, e.g., "subscriptionName", or the fully-qualified
subscription name in the projects/<project_name>/subscriptions/<subscription_name>
formatpublic List<com.google.pubsub.v1.Subscription> listSubscriptions()
If there are multiple pages, they will all be merged into the same result.
public int getDefaultAckDeadline()
public void setDefaultAckDeadline(int defaultAckDeadline)
defaultAckDeadline
- default acknowledgement deadline value in seconds, must be between 10 and 600 seconds.public void close()
close
in interface AutoCloseable
Copyright © 2021. All rights reserved.