3131 * A Cloud Pub/Sub <a href="https://cloud.google.com/pubsub/docs/publisher">publisher</a>, that is
3232 * associated with a specific topic at creation.
3333 *
34- * <p>A {@link Publisher} provides built-in capabilities to automatically handle batching of
34+ * <p>A {@link Publisher} provides built-in capabilities to automatically handle bundling of
3535 * messages, controlling memory utilization, and retrying API calls on transient errors.
3636 *
3737 * <p>With customizable options that control:
3838 *
3939 * <ul>
40- * <li>Message batching : such as number of messages or max batch byte size.
40+ * <li>Message bundling : such as number of messages or max bundle byte size.
4141 * <li>Flow control: such as max outstanding messages and maximum outstanding bytes.
42- * <li>Retries: such as the maximum duration of retries for a failing batch of messages.
42+ * <li>Retries: such as the maximum duration of retries for a failing bundle of messages.
4343 * </ul>
4444 *
4545 * <p>If no credentials are provided, the {@link Publisher} will use application default credentials
5151 * <pre>
5252 * Publisher publisher =
5353 * Publisher.Builder.newBuilder(MY_TOPIC)
54- * .setMaxBatchDuration (new Duration(10 * 1000))
54+ * .setMaxBundleDuration (new Duration(10 * 1000))
5555 * .build();
5656 * List<ListenableFuture<String>> results = new ArrayList<>();
5757 *
@@ -81,23 +81,23 @@ public interface Publisher {
8181 String PUBSUB_API_SCOPE = "https://www.googleapis.com/auth/pubsub" ;
8282
8383 // API limits.
84- int MAX_BATCH_MESSAGES = 1000 ;
85- int MAX_BATCH_BYTES = 10 * 1000 * 1000 ; // 10 megabytes (https://en.wikipedia.org/wiki/Megabyte)
84+ int MAX_BUNDLE_MESSAGES = 1000 ;
85+ int MAX_BUNDLE_BYTES = 10 * 1000 * 1000 ; // 10 megabytes (https://en.wikipedia.org/wiki/Megabyte)
8686
8787 // Meaningful defaults.
88- int DEFAULT_MAX_BATCH_MESSAGES = 100 ;
89- int DEFAULT_MAX_BATCH_BYTES = 1000 ; // 1 kB
90- Duration DEFAULT_MAX_BATCH_DURATION = new Duration (1 ); // 1ms
88+ int DEFAULT_MAX_BUNDLE_MESSAGES = 100 ;
89+ int DEFAULT_MAX_BUNDLE_BYTES = 1000 ; // 1 kB
90+ Duration DEFAULT_MAX_BUNDLE_DURATION = new Duration (1 ); // 1ms
9191 Duration DEFAULT_REQUEST_TIMEOUT = new Duration (10 * 1000 ); // 10 seconds
92- Duration MIN_SEND_BATCH_DURATION = new Duration (10 * 1000 ); // 10 seconds
92+ Duration MIN_SEND_BUNDLE_DURATION = new Duration (10 * 1000 ); // 10 seconds
9393 Duration MIN_REQUEST_TIMEOUT = new Duration (10 ); // 10 milliseconds
9494
9595 /** Topic to which the publisher publishes to. */
9696 String getTopic ();
9797
9898 /**
9999 * Schedules the publishing of a message. The publishing of the message may occur immediately or
100- * be delayed based on the publisher batching options.
100+ * be delayed based on the publisher bundling options.
101101 *
102102 * <p>Depending on chosen flow control {@link #failOnFlowControlLimits option}, the returned
103103 * future might immediately fail with a {@link CloudPubsubFlowControlException} or block the
@@ -109,13 +109,13 @@ public interface Publisher {
109109 ListenableFuture <String > publish (PubsubMessage message );
110110
111111 /** Maximum amount of time to wait until scheduling the publishing of messages. */
112- Duration getMaxBatchDuration ();
112+ Duration getMaxBundleDuration ();
113113
114- /** Maximum number of bytes to batch before publishing. */
115- long getMaxBatchBytes ();
114+ /** Maximum number of bytes to bundle before publishing. */
115+ long getMaxBundleBytes ();
116116
117- /** Maximum number of messages to batch before publishing. */
118- long getMaxBatchMessages ();
117+ /** Maximum number of messages to bundle before publishing. */
118+ long getMaxBundleMessages ();
119119
120120 /**
121121 * Maximum number of outstanding (i.e. pending to publish) messages before limits are enforced.
@@ -155,18 +155,18 @@ public interface Publisher {
155155 final class Builder {
156156 String topic ;
157157
158- // Batching options
159- int maxBatchMessages ;
160- int maxBatchBytes ;
161- Duration maxBatchDuration ;
158+ // Bundling options
159+ int maxBundleMessages ;
160+ int maxBundleBytes ;
161+ Duration maxBundleDuration ;
162162
163163 // Client-side flow control options
164164 Optional <Integer > maxOutstandingMessages ;
165165 Optional <Integer > maxOutstandingBytes ;
166166 boolean failOnFlowControlLimits ;
167167
168- // Send batch deadline
169- Duration sendBatchDeadline ;
168+ // Send bundle deadline
169+ Duration sendBundleDeadline ;
170170
171171 // RPC options
172172 Duration requestTimeout ;
@@ -192,11 +192,11 @@ private void setDefaults() {
192192 channelBuilder = Optional .absent ();
193193 maxOutstandingMessages = Optional .absent ();
194194 maxOutstandingBytes = Optional .absent ();
195- maxBatchMessages = DEFAULT_MAX_BATCH_MESSAGES ;
196- maxBatchBytes = DEFAULT_MAX_BATCH_BYTES ;
197- maxBatchDuration = DEFAULT_MAX_BATCH_DURATION ;
195+ maxBundleMessages = DEFAULT_MAX_BUNDLE_MESSAGES ;
196+ maxBundleBytes = DEFAULT_MAX_BUNDLE_BYTES ;
197+ maxBundleDuration = DEFAULT_MAX_BUNDLE_DURATION ;
198198 requestTimeout = DEFAULT_REQUEST_TIMEOUT ;
199- sendBatchDeadline = MIN_SEND_BATCH_DURATION ;
199+ sendBundleDeadline = MIN_SEND_BUNDLE_DURATION ;
200200 failOnFlowControlLimits = false ;
201201 executor = Optional .absent ();
202202 }
@@ -224,16 +224,16 @@ public Builder setChannelBuilder(
224224 return this ;
225225 }
226226
227- // Batching options
227+ // Bundling options
228228
229229 /**
230230 * Maximum number of messages to send per publish call.
231231 *
232232 * <p>It also sets a target to when to trigger a publish.
233233 */
234- public Builder setMaxBatchMessages (int messages ) {
234+ public Builder setMaxBundleMessages (int messages ) {
235235 Preconditions .checkArgument (messages > 0 );
236- maxBatchMessages = messages ;
236+ maxBundleMessages = messages ;
237237 return this ;
238238 }
239239
@@ -244,19 +244,19 @@ public Builder setMaxBatchMessages(int messages) {
244244 *
245245 * <p>This will not be honored if a single message is published that exceeds this maximum.
246246 */
247- public Builder setMaxBatchBytes (int bytes ) {
247+ public Builder setMaxBundleBytes (int bytes ) {
248248 Preconditions .checkArgument (bytes > 0 );
249- maxBatchBytes = bytes ;
249+ maxBundleBytes = bytes ;
250250 return this ;
251251 }
252252
253253 /**
254- * Time to wait, since the first message is kept in memory for batching , before triggering a
254+ * Time to wait, since the first message is kept in memory for bundling , before triggering a
255255 * publish call.
256256 */
257- public Builder setMaxBatchDuration (Duration duration ) {
257+ public Builder setMaxBundleDuration (Duration duration ) {
258258 Preconditions .checkArgument (duration .getMillis () >= 0 );
259- maxBatchDuration = duration ;
259+ maxBundleDuration = duration ;
260260 return this ;
261261 }
262262
@@ -289,10 +289,10 @@ public Builder setFailOnFlowControlLimits(boolean fail) {
289289 return this ;
290290 }
291291
292- /** Maximum time to attempt sending (and retrying) a batch of messages before giving up. */
293- public Builder setSendBatchDeadline (Duration deadline ) {
294- Preconditions .checkArgument (deadline .compareTo (MIN_SEND_BATCH_DURATION ) >= 0 );
295- sendBatchDeadline = deadline ;
292+ /** Maximum time to attempt sending (and retrying) a bundle of messages before giving up. */
293+ public Builder setSendBundleDeadline (Duration deadline ) {
294+ Preconditions .checkArgument (deadline .compareTo (MIN_SEND_BUNDLE_DURATION ) >= 0 );
295+ sendBundleDeadline = deadline ;
296296 return this ;
297297 }
298298
@@ -329,14 +329,14 @@ public MaxOutstandingMessagesReachedException(int currentMaxMessages) {
329329 this .currentMaxMessages = currentMaxMessages ;
330330 }
331331
332- public int getCurrentMaxBatchMessages () {
332+ public int getCurrentMaxBundleMessages () {
333333 return currentMaxMessages ;
334334 }
335335
336336 @ Override
337337 public String toString () {
338338 return String .format (
339- "The maximum number of batch messages: %d have been reached." , currentMaxMessages );
339+ "The maximum number of bundle messages: %d have been reached." , currentMaxMessages );
340340 }
341341 }
342342
@@ -351,14 +351,14 @@ public MaxOutstandingBytesReachedException(int currentMaxBytes) {
351351 this .currentMaxBytes = currentMaxBytes ;
352352 }
353353
354- public int getCurrentMaxBatchBytes () {
354+ public int getCurrentMaxBundleBytes () {
355355 return currentMaxBytes ;
356356 }
357357
358358 @ Override
359359 public String toString () {
360360 return String .format (
361- "The maximum number of batch bytes: %d have been reached." , currentMaxBytes );
361+ "The maximum number of bundle bytes: %d have been reached." , currentMaxBytes );
362362 }
363363 }
364364}
0 commit comments