Class PubsubJsonClient
- java.lang.Object
-
- org.apache.beam.sdk.io.gcp.pubsub.PubsubClient
-
- org.apache.beam.sdk.io.gcp.pubsub.PubsubJsonClient
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class PubsubJsonClient extends PubsubClient
A Pubsub client using JSON transport.
-
-
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
Fields Modifier and Type Field Description static PubsubClient.PubsubClientFactoryFACTORYFactory for creating Pubsub clients using Json transport.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intackDeadlineSeconds(PubsubClient.SubscriptionPath subscription)Return the ack deadline, in seconds, forsubscription.voidacknowledge(PubsubClient.SubscriptionPath subscription, java.util.List<java.lang.String> ackIds)Acknowldege messages fromsubscriptionwithackIds.voidclose()voidcreateSchema(PubsubClient.SchemaPath schemaPath, java.lang.String schemaContent, com.google.pubsub.v1.Schema.Type type)CreateSchemafrom Schema definition content.voidcreateSubscription(PubsubClient.TopicPath topic, PubsubClient.SubscriptionPath subscription, int ackDeadlineSeconds)Createsubscriptiontotopic.voidcreateTopic(PubsubClient.TopicPath topic)Createtopic.voidcreateTopic(PubsubClient.TopicPath topic, PubsubClient.SchemaPath schema)Create {link TopicPath} withPubsubClient.SchemaPath.voiddeleteSchema(PubsubClient.SchemaPath schemaPath)DeletePubsubClient.SchemaPath.voiddeleteSubscription(PubsubClient.SubscriptionPath subscription)Deletesubscription.voiddeleteTopic(PubsubClient.TopicPath topic)org.apache.beam.sdk.schemas.SchemagetSchema(PubsubClient.SchemaPath schemaPath)Return a BeamSchemafrom the Pub/Sub schema resource, if exists.PubsubClient.SchemaPathgetSchemaPath(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.booleanisTopicExists(PubsubClient.TopicPath topic)Return true iftopicexists.java.util.List<PubsubClient.SubscriptionPath>listSubscriptions(PubsubClient.ProjectPath project, PubsubClient.TopicPath topic)Return a list of subscriptions fortopicinproject.java.util.List<PubsubClient.TopicPath>listTopics(PubsubClient.ProjectPath project)Return a list of topics forproject.voidmodifyAckDeadline(PubsubClient.SubscriptionPath subscription, java.util.List<java.lang.String> ackIds, int deadlineSeconds)Modify the ack deadline for messages fromsubscriptionwithackIdsto bedeadlineSecondsfrom now.intpublish(PubsubClient.TopicPath topic, java.util.List<PubsubClient.OutgoingMessage> outgoingMessages)PublishoutgoingMessagesto Pubsubtopic.java.util.List<PubsubClient.IncomingMessage>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 Detail
-
FACTORY
public static final PubsubClient.PubsubClientFactory FACTORY
Factory for creating Pubsub clients using Json transport.
-
-
Method Detail
-
close
public void close()
-
publish
public int publish(PubsubClient.TopicPath topic, java.util.List<PubsubClient.OutgoingMessage> outgoingMessages) throws java.io.IOException
Description copied from class:PubsubClientPublishoutgoingMessagesto Pubsubtopic. Return number of messages published.- Specified by:
publishin classPubsubClient- Throws:
java.io.IOException
-
pull
public java.util.List<PubsubClient.IncomingMessage> pull(long requestTimeMsSinceEpoch, PubsubClient.SubscriptionPath subscription, int batchSize, boolean returnImmediately) throws java.io.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:
java.io.IOException
-
acknowledge
public void acknowledge(PubsubClient.SubscriptionPath subscription, java.util.List<java.lang.String> ackIds) throws java.io.IOException
Description copied from class:PubsubClientAcknowldege messages fromsubscriptionwithackIds.- Specified by:
acknowledgein classPubsubClient- Throws:
java.io.IOException
-
modifyAckDeadline
public void modifyAckDeadline(PubsubClient.SubscriptionPath subscription, java.util.List<java.lang.String> ackIds, int deadlineSeconds) throws java.io.IOException
Description copied from class:PubsubClientModify the ack deadline for messages fromsubscriptionwithackIdsto bedeadlineSecondsfrom now.- Specified by:
modifyAckDeadlinein classPubsubClient- Throws:
java.io.IOException
-
createTopic
public void createTopic(PubsubClient.TopicPath topic) throws java.io.IOException
Description copied from class:PubsubClientCreatetopic.- Specified by:
createTopicin classPubsubClient- Throws:
java.io.IOException
-
createTopic
public void createTopic(PubsubClient.TopicPath topic, PubsubClient.SchemaPath schema) throws java.io.IOException
Description copied from class:PubsubClientCreate {link TopicPath} withPubsubClient.SchemaPath.- Specified by:
createTopicin classPubsubClient- Throws:
java.io.IOException
-
deleteTopic
public void deleteTopic(PubsubClient.TopicPath topic) throws java.io.IOException
- Specified by:
deleteTopicin classPubsubClient- Throws:
java.io.IOException
-
listTopics
public java.util.List<PubsubClient.TopicPath> listTopics(PubsubClient.ProjectPath project) throws java.io.IOException
Description copied from class:PubsubClientReturn a list of topics forproject.- Specified by:
listTopicsin classPubsubClient- Throws:
java.io.IOException
-
isTopicExists
public boolean isTopicExists(PubsubClient.TopicPath topic) throws java.io.IOException
Description copied from class:PubsubClientReturn true iftopicexists.- Specified by:
isTopicExistsin classPubsubClient- Throws:
java.io.IOException
-
createSubscription
public void createSubscription(PubsubClient.TopicPath topic, PubsubClient.SubscriptionPath subscription, int ackDeadlineSeconds) throws java.io.IOException
Description copied from class:PubsubClientCreatesubscriptiontotopic.- Specified by:
createSubscriptionin classPubsubClient- Throws:
java.io.IOException
-
deleteSubscription
public void deleteSubscription(PubsubClient.SubscriptionPath subscription) throws java.io.IOException
Description copied from class:PubsubClientDeletesubscription.- Specified by:
deleteSubscriptionin classPubsubClient- Throws:
java.io.IOException
-
listSubscriptions
public java.util.List<PubsubClient.SubscriptionPath> listSubscriptions(PubsubClient.ProjectPath project, PubsubClient.TopicPath topic) throws java.io.IOException
Description copied from class:PubsubClientReturn a list of subscriptions fortopicinproject.- Specified by:
listSubscriptionsin classPubsubClient- Throws:
java.io.IOException
-
ackDeadlineSeconds
public int ackDeadlineSeconds(PubsubClient.SubscriptionPath subscription) throws java.io.IOException
Description copied from class:PubsubClientReturn the ack deadline, in seconds, forsubscription.- Specified by:
ackDeadlineSecondsin classPubsubClient- Throws:
java.io.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, java.lang.String schemaContent, com.google.pubsub.v1.Schema.Type type) throws java.io.IOException
CreateSchemafrom Schema definition content.- Specified by:
createSchemain classPubsubClient- Throws:
java.io.IOException
-
deleteSchema
public void deleteSchema(PubsubClient.SchemaPath schemaPath) throws java.io.IOException
DeletePubsubClient.SchemaPath.- Specified by:
deleteSchemain classPubsubClient- Throws:
java.io.IOException
-
getSchemaPath
public PubsubClient.SchemaPath getSchemaPath(PubsubClient.TopicPath topicPath) throws java.io.IOException
ReturnPubsubClient.SchemaPathfromPubsubClient.TopicPathif exists.- Specified by:
getSchemaPathin classPubsubClient- Throws:
java.io.IOException
-
getSchema
public org.apache.beam.sdk.schemas.Schema getSchema(PubsubClient.SchemaPath schemaPath) throws java.io.IOException
Return a BeamSchemafrom the Pub/Sub schema resource, if exists.- Specified by:
getSchemain classPubsubClient- Throws:
java.io.IOException
-
-