Class PubsubGrpcClient
java.lang.Object
org.apache.beam.sdk.io.gcp.pubsub.PubsubClient
org.apache.beam.sdk.io.gcp.pubsub.PubsubGrpcClient
- All Implemented Interfaces:
Closeable,AutoCloseable
A helper class for talking to Pubsub via grpc.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.beam.sdk.io.gcp.pubsub.PubsubClient
PubsubClient.IncomingMessage, PubsubClient.OutgoingMessage, PubsubClient.ProjectPath, PubsubClient.PubsubClientFactory, PubsubClient.SchemaPath, PubsubClient.SubscriptionPath, PubsubClient.TopicPath -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PubsubClient.PubsubClientFactoryFactory for creating Pubsub clients using gRPC transport. -
Method Summary
Modifier and TypeMethodDescriptionintackDeadlineSeconds(PubsubClient.SubscriptionPath subscription) Return the ack deadline, in seconds, forsubscription.voidacknowledge(PubsubClient.SubscriptionPath subscription, List<String> ackIds) Acknowldege messages fromsubscriptionwithackIds.voidclose()Gracefully close the underlying netty channel.voidcreateSchema(PubsubClient.SchemaPath schemaPath, String schemaContent, com.google.pubsub.v1.Schema.Type type) CreateSchemafrom Schema definition content.voidcreateSubscription(PubsubClient.TopicPath topic, PubsubClient.SubscriptionPath subscription, int ackDeadlineSeconds) Createsubscriptiontotopic.voidCreatetopic.voidcreateTopic(PubsubClient.TopicPath topic, PubsubClient.SchemaPath schema) Create {link TopicPath} withPubsubClient.SchemaPath.voiddeleteSchema(PubsubClient.SchemaPath schemaPath) DeletePubsubClient.SchemaPath.voiddeleteSubscription(PubsubClient.SubscriptionPath subscription) Deletesubscription.voidgetSchema(PubsubClient.SchemaPath schemaPath) Return a BeamSchemafrom the Pub/Sub schema resource, if exists.getSchemaPath(PubsubClient.TopicPath topicPath) ReturnPubsubClient.SchemaPathfromPubsubClient.TopicPathif exists.booleanisEOF()Return true ifPubsubClient.pull(long, org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.SubscriptionPath, int, boolean)will always return empty list.booleanReturn true iftopicexists.listSubscriptions(PubsubClient.ProjectPath project, PubsubClient.TopicPath topic) Return a list of subscriptions fortopicinproject.listTopics(PubsubClient.ProjectPath project) Return a list of topics forproject.voidmodifyAckDeadline(PubsubClient.SubscriptionPath subscription, List<String> ackIds, int deadlineSeconds) Modify the ack deadline for messages fromsubscriptionwithackIdsto bedeadlineSecondsfrom now.intpublish(PubsubClient.TopicPath topic, List<PubsubClient.OutgoingMessage> outgoingMessages) PublishoutgoingMessagesto Pubsubtopic.pull(long requestTimeMsSinceEpoch, PubsubClient.SubscriptionPath subscription, int batchSize, boolean returnImmediately) Request the next batch of up tobatchSizemessages fromsubscription.Methods inherited from class org.apache.beam.sdk.io.gcp.pubsub.PubsubClient
createRandomSubscription, extractTimestampAttribute, parseTimestampAsMsSinceEpoch, projectPathFromId, projectPathFromPath, schemaPathFromId, schemaPathFromPath, subscriptionPathFromName, subscriptionPathFromPath, topicPathFromName, topicPathFromPath
-
Field Details
-
FACTORY
Factory for creating Pubsub clients using gRPC transport.
-
-
Method Details
-
close
public void close()Gracefully close the underlying netty channel. -
publish
public int publish(PubsubClient.TopicPath topic, List<PubsubClient.OutgoingMessage> outgoingMessages) throws IOException Description copied from class:PubsubClientPublishoutgoingMessagesto Pubsubtopic. Return number of messages published.- Specified by:
publishin classPubsubClient- Throws:
IOException
-
pull
public List<PubsubClient.IncomingMessage> pull(long requestTimeMsSinceEpoch, PubsubClient.SubscriptionPath subscription, int batchSize, boolean returnImmediately) throws IOException Description copied from class:PubsubClientRequest the next batch of up tobatchSizemessages fromsubscription. Return the received messages, or empty collection if none were available. Does not wait for messages to arrive ifreturnImmediatelyis true. Returned messages will record their request time asrequestTimeMsSinceEpoch.- Specified by:
pullin classPubsubClient- Throws:
IOException
-
acknowledge
public void acknowledge(PubsubClient.SubscriptionPath subscription, List<String> ackIds) throws IOException Description copied from class:PubsubClientAcknowldege messages fromsubscriptionwithackIds.- Specified by:
acknowledgein classPubsubClient- Throws:
IOException
-
modifyAckDeadline
public void modifyAckDeadline(PubsubClient.SubscriptionPath subscription, List<String> ackIds, int deadlineSeconds) throws IOException Description copied from class:PubsubClientModify the ack deadline for messages fromsubscriptionwithackIdsto bedeadlineSecondsfrom now.- Specified by:
modifyAckDeadlinein classPubsubClient- Throws:
IOException
-
createTopic
Description copied from class:PubsubClientCreatetopic.- Specified by:
createTopicin classPubsubClient- Throws:
IOException
-
createTopic
public void createTopic(PubsubClient.TopicPath topic, PubsubClient.SchemaPath schema) throws IOException Description copied from class:PubsubClientCreate {link TopicPath} withPubsubClient.SchemaPath.- Specified by:
createTopicin classPubsubClient- Throws:
IOException
-
deleteTopic
- Specified by:
deleteTopicin classPubsubClient- Throws:
IOException
-
listTopics
Description copied from class:PubsubClientReturn a list of topics forproject.- Specified by:
listTopicsin classPubsubClient- Throws:
IOException
-
isTopicExists
Description copied from class:PubsubClientReturn true iftopicexists.- Specified by:
isTopicExistsin classPubsubClient- Throws:
IOException
-
createSubscription
public void createSubscription(PubsubClient.TopicPath topic, PubsubClient.SubscriptionPath subscription, int ackDeadlineSeconds) throws IOException Description copied from class:PubsubClientCreatesubscriptiontotopic.- Specified by:
createSubscriptionin classPubsubClient- Throws:
IOException
-
deleteSubscription
Description copied from class:PubsubClientDeletesubscription.- Specified by:
deleteSubscriptionin classPubsubClient- Throws:
IOException
-
listSubscriptions
public List<PubsubClient.SubscriptionPath> listSubscriptions(PubsubClient.ProjectPath project, PubsubClient.TopicPath topic) throws IOException Description copied from class:PubsubClientReturn a list of subscriptions fortopicinproject.- Specified by:
listSubscriptionsin classPubsubClient- Throws:
IOException
-
ackDeadlineSeconds
Description copied from class:PubsubClientReturn the ack deadline, in seconds, forsubscription.- Specified by:
ackDeadlineSecondsin classPubsubClient- Throws:
IOException
-
isEOF
public boolean isEOF()Description copied from class:PubsubClientReturn true ifPubsubClient.pull(long, org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.SubscriptionPath, int, boolean)will always return empty list. Actual clients will return false. Test clients may return true to signal that all expected messages have been pulled and the test may complete.- Specified by:
isEOFin classPubsubClient
-
createSchema
public void createSchema(PubsubClient.SchemaPath schemaPath, String schemaContent, com.google.pubsub.v1.Schema.Type type) throws IOException CreateSchemafrom Schema definition content.- Specified by:
createSchemain classPubsubClient- Throws:
IOException
-
deleteSchema
DeletePubsubClient.SchemaPath.- Specified by:
deleteSchemain classPubsubClient- Throws:
IOException
-
getSchemaPath
ReturnPubsubClient.SchemaPathfromPubsubClient.TopicPathif exists.- Specified by:
getSchemaPathin classPubsubClient- Throws:
IOException
-
getSchema
Return a BeamSchemafrom the Pub/Sub schema resource, if exists.- Specified by:
getSchemain classPubsubClient- Throws:
IOException
-