@@ -47,6 +47,14 @@ enum OptionType implements Option.OptionType {
47
47
<T > T get (Map <Option .OptionType , ?> options ) {
48
48
return (T ) options .get (this );
49
49
}
50
+
51
+ String getString (Map <Option .OptionType , ?> options ) {
52
+ return get (options );
53
+ }
54
+
55
+ Integer getInteger (Map <Option .OptionType , ?> options ) {
56
+ return get (options );
57
+ }
50
58
}
51
59
52
60
private ListOption (OptionType option , Object value ) {
@@ -73,27 +81,31 @@ public static ListOption pageToken(String pageToken) {
73
81
*/
74
82
final class PullOption extends Option {
75
83
76
- private static final long serialVersionUID = - 5220474819637439937L ;
84
+ private static final long serialVersionUID = 4792164134340316582L ;
77
85
78
86
enum OptionType implements Option .OptionType {
79
- MAX_MESSAGES ;
87
+ MAX_CONCURRENT_CALLBACKS ;
80
88
81
89
@ SuppressWarnings ("unchecked" )
82
90
<T > T get (Map <Option .OptionType , ?> options ) {
83
91
return (T ) options .get (this );
84
92
}
93
+
94
+ Integer getInteger (Map <Option .OptionType , ?> options ) {
95
+ return get (options );
96
+ }
85
97
}
86
98
87
- private PullOption (OptionType option , Object value ) {
99
+ private PullOption (Option . OptionType option , Object value ) {
88
100
super (option , value );
89
101
}
90
102
91
103
/**
92
- * Returns an option to specify the maximum number of messages that can be returned by the pull
93
- * operation .
104
+ * Returns an option to specify the maximum number of messages that can be executed
105
+ * concurrently at any time .
94
106
*/
95
- public static PullOption maxMessages (int maxMessages ) {
96
- return new PullOption (OptionType .MAX_MESSAGES , maxMessages );
107
+ public static PullOption maxConcurrentCallbacks (int maxConcurrency ) {
108
+ return new PullOption (OptionType .MAX_CONCURRENT_CALLBACKS , maxConcurrency );
97
109
}
98
110
}
99
111
@@ -110,38 +122,6 @@ interface MessageProcessor {
110
122
*/
111
123
interface MessageConsumer extends AutoCloseable {
112
124
113
- /**
114
- * Class for specifying options to pull messages through a {@code MessageConsumer}.
115
- */
116
- final class PullOption extends Option {
117
-
118
- private static final long serialVersionUID = 4792164134340316582L ;
119
-
120
- enum OptionType implements Option .OptionType {
121
- MAX_CONCURRENT_CALLBACKS ;
122
-
123
- @ SuppressWarnings ("unchecked" )
124
- <T > T get (Map <OptionType , ?> options ) {
125
- return (T ) options .get (this );
126
- }
127
- }
128
-
129
- private PullOption (OptionType option , Object value ) {
130
- super (option , value );
131
- }
132
-
133
- /**
134
- * Returns an option to specify the maximum number of messages that can be executed
135
- * concurrently at any time.
136
- */
137
- public static PullOption maxConcurrentCallbacks (int maxConcurrency ) {
138
- return new PullOption (OptionType .MAX_CONCURRENT_CALLBACKS , maxConcurrency );
139
- }
140
- }
141
-
142
- void start (MessageConsumer .PullOption ... options );
143
-
144
- void stop ();
145
125
}
146
126
147
127
Topic create (TopicInfo topic );
@@ -200,11 +180,11 @@ public static PullOption maxConcurrentCallbacks(int maxConcurrency) {
200
180
201
181
Future <AsyncPage <SubscriptionId >> listSubscriptionsAsync (String topic , ListOption ... options );
202
182
203
- Iterator <ReceivedMessage > pull (String subscription , PullOption ... options );
183
+ Iterator <ReceivedMessage > pull (String subscription , int maxMessages );
204
184
205
- Future <Iterator <ReceivedMessage >> pullAsync (String subscription , PullOption ... options );
185
+ Future <Iterator <ReceivedMessage >> pullAsync (String subscription , int maxMessages );
206
186
207
- MessageConsumer pullAsync (String subscription , MessageProcessor callback );
187
+ MessageConsumer pullAsync (String subscription , MessageProcessor callback , PullOption ... options );
208
188
209
189
void ack (String subscription , String ackId , String ... ackIds );
210
190
0 commit comments