-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
api: pubsubIssues related to the Pub/Sub API.Issues related to the Pub/Sub API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.
Description
Can someone please provide an example of limiting the number of pulling pubsub threads with the new API so we can start testing?
In the old API it was possible to limit the number of concurrent threads that pulled messages with the following code:
PubSub.MessageConsumer consumer = pubsub.pullAsync(
subscription,
messageProcessor,
PubSub.PullOption.maxQueuedCallbacks(maxQueuedCallbacks),
PubSub.PullOption.executorFactory(executorFactory)
);where maxQueuedCallbacks was an integer amount of msgs to pull and
executorFactory was provided from this
/**
* Create an ExecutorFactory instance for use with a single
* {@link PubSub.MessageConsumer}.
*
* <p>The number of threads in the executor determines how many messages can be processed at one
* time.</p>
*
* @see PubSub.PullOption#executorFactory(ExecutorFactory)
*/
private static ExecutorFactory<ExecutorService> createExecutor(
final int threads,
final String threadNameFormat) {
final ThreadFactory threadFactory = new ThreadFactoryBuilder()
.setDaemon(true)
.setNameFormat(threadNameFormat)
.build();
final ExecutorService executorService = Executors.newFixedThreadPool(threads, threadFactory);
return new ExecutorFactory<ExecutorService>() {
@Override
public ExecutorService get() {
return executorService;
}
@Override
public void release(final ExecutorService executor) {
executorService.shutdownNow();
}
};
}Metadata
Metadata
Assignees
Labels
api: pubsubIssues related to the Pub/Sub API.Issues related to the Pub/Sub API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.