Interface SubscriberFactory
- All Known Implementing Classes:
DefaultSubscriberFactory
public interface SubscriberFactory
Interface used by the
PubSubTemplate
to create
supporting objects for consuming messages from Pub/Sub subscriptions.-
Method Summary
Modifier and TypeMethodDescriptioncom.google.pubsub.v1.PullRequest
createPullRequest
(String subscriptionName, Integer maxMessages, Boolean returnImmediately) Create aPullRequest
for synchronously pulling a number of messages from a Google Cloud Pub/Sub subscription.com.google.cloud.pubsub.v1.Subscriber
createSubscriber
(String subscriptionName, com.google.cloud.pubsub.v1.MessageReceiver receiver) Create aSubscriber
for the specified subscription name and wired it up to asynchronously deliver messages to the providedMessageReceiver
.com.google.cloud.pubsub.v1.stub.SubscriberStub
createSubscriberStub
(String subscriptionName) Create aSubscriberStub
that is needed to executePullRequest
s.Method to get the project id.
-
Method Details
-
getProjectId
String getProjectId()Method to get the project id.- Returns:
- the project id
- Since:
- 1.1
-
createSubscriber
com.google.cloud.pubsub.v1.Subscriber createSubscriber(String subscriptionName, com.google.cloud.pubsub.v1.MessageReceiver receiver) Create aSubscriber
for the specified subscription name and wired it up to asynchronously deliver messages to the providedMessageReceiver
.- Parameters:
subscriptionName
- the name of the subscriptionreceiver
- the callback for receiving messages asynchronously- Returns:
- the
Subscriber
that was created to bind the receiver to the subscription
-
createPullRequest
com.google.pubsub.v1.PullRequest createPullRequest(String subscriptionName, Integer maxMessages, Boolean returnImmediately) Create aPullRequest
for synchronously pulling a number of messages from a Google Cloud Pub/Sub subscription.- Parameters:
subscriptionName
- the name of the subscriptionmaxMessages
- the maximum number of pulled messages; must be greater than zero. If null is passed in, then up to Integer.MAX_VALUE messages will be requested.returnImmediately
- causes the pull request to return immediately even if subscription doesn't contain enough messages to satisfymaxMessages
. Setting this parameter totrue
is not recommended as it may result in long delays in message delivery.- Returns:
- the pull request that can be executed using a
SubscriberStub
-
createSubscriberStub
Create aSubscriberStub
that is needed to executePullRequest
s.- Parameters:
subscriptionName
- the subscription name- Returns:
- the
SubscriberStub
used for executingPullRequest
s
-