use of com.google.api.gax.batching.BatchingSettings in project google-cloud-java by GoogleCloudPlatform.
the class PublisherSnippets method getPublisherWithCustomBatchSettings.
public Publisher getPublisherWithCustomBatchSettings(TopicName topicName) throws Exception {
// [START pubsub_publisher_batch_settings]
// Batch settings control how the publisher batches messages
// default : 1kb
long requestBytesThreshold = 5000L;
// default : 100
long messageCountBatchSize = 10L;
// default : 1 ms
Duration publishDelayThreshold = Duration.ofMillis(100);
// Publish request get triggered based on request size, messages count & time since last publish
BatchingSettings batchingSettings = BatchingSettings.newBuilder().setElementCountThreshold(messageCountBatchSize).setRequestByteThreshold(requestBytesThreshold).setDelayThreshold(publishDelayThreshold).build();
Publisher publisher = Publisher.defaultBuilder(topicName).setBatchingSettings(batchingSettings).build();
// [END pubsub_publisher_batch_settings]
return publisher;
}
use of com.google.api.gax.batching.BatchingSettings in project divolte-collector by divolte.
the class GoogleCloudPubSubSinkConfiguration method getFactory.
@Override
public SinkFactory getFactory() {
final RetrySettings retrySettings = this.retrySettings.createRetrySettings();
final BatchingSettings batchingSettings = this.batchingSettings.createBatchingSettings();
final Optional<String> emulator = Optional.ofNullable(System.getenv("PUBSUB_EMULATOR_HOST"));
return emulator.map(hostport -> createFlushingPool(retrySettings, batchingSettings, hostport)).orElseGet(() -> createFlushingPool(retrySettings, batchingSettings));
}
use of com.google.api.gax.batching.BatchingSettings in project divolte-collector by divolte.
the class GoogleCloudPubSubSinkConfigurationTest method testDefaultBatchingConfigurationValid.
@Test
public void testDefaultBatchingConfigurationValid() {
// Check that we can generate settings from our defaults.
final BatchingSettings batchingSettings = GoogleCloudPubSubSinkConfiguration.DEFAULT_BATCHING_SETTINGS.createBatchingSettings();
assertNotNull(batchingSettings);
}
Aggregations