Class PubsubJsonClient
java.lang.Object
org.apache.beam.sdk.io.gcp.pubsub.PubsubClient
org.apache.beam.sdk.io.gcp.pubsub.PubsubJsonClient
- All Implemented Interfaces:
Closeable
,AutoCloseable
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
FieldsModifier and TypeFieldDescriptionstatic final PubsubClient.PubsubClientFactory
Factory for creating Pubsub clients using Json transport. -
Method Summary
Modifier and TypeMethodDescriptionint
ackDeadlineSeconds
(PubsubClient.SubscriptionPath subscription) Return the ack deadline, in seconds, forsubscription
.void
acknowledge
(PubsubClient.SubscriptionPath subscription, List<String> ackIds) Acknowldege messages fromsubscription
withackIds
.void
close()
void
createSchema
(PubsubClient.SchemaPath schemaPath, String schemaContent, com.google.pubsub.v1.Schema.Type type) CreateSchema
from Schema definition content.void
createSubscription
(PubsubClient.TopicPath topic, PubsubClient.SubscriptionPath subscription, int ackDeadlineSeconds) Createsubscription
totopic
.void
Createtopic
.void
createTopic
(PubsubClient.TopicPath topic, PubsubClient.SchemaPath schema) Create {link TopicPath} withPubsubClient.SchemaPath
.void
deleteSchema
(PubsubClient.SchemaPath schemaPath) DeletePubsubClient.SchemaPath
.void
deleteSubscription
(PubsubClient.SubscriptionPath subscription) Deletesubscription
.void
getSchema
(PubsubClient.SchemaPath schemaPath) Return a BeamSchema
from the Pub/Sub schema resource, if exists.getSchemaPath
(PubsubClient.TopicPath topicPath) ReturnPubsubClient.SchemaPath
fromPubsubClient.TopicPath
if exists.boolean
isEOF()
Return true ifPubsubClient.pull(long, org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.SubscriptionPath, int, boolean)
will always return empty list.boolean
Return true iftopic
exists.listSubscriptions
(PubsubClient.ProjectPath project, PubsubClient.TopicPath topic) Return a list of subscriptions fortopic
inproject
.listTopics
(PubsubClient.ProjectPath project) Return a list of topics forproject
.void
modifyAckDeadline
(PubsubClient.SubscriptionPath subscription, List<String> ackIds, int deadlineSeconds) Modify the ack deadline for messages fromsubscription
withackIds
to bedeadlineSeconds
from now.int
publish
(PubsubClient.TopicPath topic, List<PubsubClient.OutgoingMessage> outgoingMessages) PublishoutgoingMessages
to Pubsubtopic
.pull
(long requestTimeMsSinceEpoch, PubsubClient.SubscriptionPath subscription, int batchSize, boolean returnImmediately) Request the next batch of up tobatchSize
messages 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 Json transport.
-
-
Method Details
-
close
public void close() -
publish
public int publish(PubsubClient.TopicPath topic, List<PubsubClient.OutgoingMessage> outgoingMessages) throws IOException Description copied from class:PubsubClient
PublishoutgoingMessages
to Pubsubtopic
. Return number of messages published.- Specified by:
publish
in classPubsubClient
- Throws:
IOException
-
pull
public List<PubsubClient.IncomingMessage> pull(long requestTimeMsSinceEpoch, PubsubClient.SubscriptionPath subscription, int batchSize, boolean returnImmediately) throws IOException Description copied from class:PubsubClient
Request the next batch of up tobatchSize
messages fromsubscription
. Return the received messages, or empty collection if none were available. Does not wait for messages to arrive ifreturnImmediately
is true. Returned messages will record their request time asrequestTimeMsSinceEpoch
.- Specified by:
pull
in classPubsubClient
- Throws:
IOException
-
acknowledge
public void acknowledge(PubsubClient.SubscriptionPath subscription, List<String> ackIds) throws IOException Description copied from class:PubsubClient
Acknowldege messages fromsubscription
withackIds
.- Specified by:
acknowledge
in classPubsubClient
- Throws:
IOException
-
modifyAckDeadline
public void modifyAckDeadline(PubsubClient.SubscriptionPath subscription, List<String> ackIds, int deadlineSeconds) throws IOException Description copied from class:PubsubClient
Modify the ack deadline for messages fromsubscription
withackIds
to bedeadlineSeconds
from now.- Specified by:
modifyAckDeadline
in classPubsubClient
- Throws:
IOException
-
createTopic
Description copied from class:PubsubClient
Createtopic
.- Specified by:
createTopic
in classPubsubClient
- Throws:
IOException
-
createTopic
public void createTopic(PubsubClient.TopicPath topic, PubsubClient.SchemaPath schema) throws IOException Description copied from class:PubsubClient
Create {link TopicPath} withPubsubClient.SchemaPath
.- Specified by:
createTopic
in classPubsubClient
- Throws:
IOException
-
deleteTopic
- Specified by:
deleteTopic
in classPubsubClient
- Throws:
IOException
-
listTopics
Description copied from class:PubsubClient
Return a list of topics forproject
.- Specified by:
listTopics
in classPubsubClient
- Throws:
IOException
-
isTopicExists
Description copied from class:PubsubClient
Return true iftopic
exists.- Specified by:
isTopicExists
in classPubsubClient
- Throws:
IOException
-
createSubscription
public void createSubscription(PubsubClient.TopicPath topic, PubsubClient.SubscriptionPath subscription, int ackDeadlineSeconds) throws IOException Description copied from class:PubsubClient
Createsubscription
totopic
.- Specified by:
createSubscription
in classPubsubClient
- Throws:
IOException
-
deleteSubscription
Description copied from class:PubsubClient
Deletesubscription
.- Specified by:
deleteSubscription
in classPubsubClient
- Throws:
IOException
-
listSubscriptions
public List<PubsubClient.SubscriptionPath> listSubscriptions(PubsubClient.ProjectPath project, PubsubClient.TopicPath topic) throws IOException Description copied from class:PubsubClient
Return a list of subscriptions fortopic
inproject
.- Specified by:
listSubscriptions
in classPubsubClient
- Throws:
IOException
-
ackDeadlineSeconds
Description copied from class:PubsubClient
Return the ack deadline, in seconds, forsubscription
.- Specified by:
ackDeadlineSeconds
in classPubsubClient
- Throws:
IOException
-
isEOF
public boolean isEOF()Description copied from class:PubsubClient
Return 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:
isEOF
in classPubsubClient
-
createSchema
public void createSchema(PubsubClient.SchemaPath schemaPath, String schemaContent, com.google.pubsub.v1.Schema.Type type) throws IOException CreateSchema
from Schema definition content.- Specified by:
createSchema
in classPubsubClient
- Throws:
IOException
-
deleteSchema
DeletePubsubClient.SchemaPath
.- Specified by:
deleteSchema
in classPubsubClient
- Throws:
IOException
-
getSchemaPath
ReturnPubsubClient.SchemaPath
fromPubsubClient.TopicPath
if exists.- Specified by:
getSchemaPath
in classPubsubClient
- Throws:
IOException
-
getSchema
Return a BeamSchema
from the Pub/Sub schema resource, if exists.- Specified by:
getSchema
in classPubsubClient
- Throws:
IOException
-