File tree Expand file tree Collapse file tree 5 files changed +10
-12
lines changed
google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets
main/java/com/google/cloud/pubsub/spi/v1
test/java/com/google/cloud/pubsub/it Expand file tree Collapse file tree 5 files changed +10
-12
lines changed Original file line number Diff line number Diff line change 2222
2323package com .google .cloud .examples .pubsub .snippets ;
2424
25- import com .google .cloud .pubsub .spi .v1 .AckReply ;
2625import com .google .cloud .pubsub .spi .v1 .AckReplyConsumer ;
2726import com .google .cloud .pubsub .spi .v1 .MessageReceiver ;
2827import com .google .pubsub .v1 .PubsubMessage ;
Original file line number Diff line number Diff line change @@ -158,7 +158,6 @@ With Pub/Sub you can pull messages from a subscription. Add the following import
158158file:
159159
160160``` java
161- import com.google.cloud.pubsub.spi.v1.AckReply ;
162161import com.google.cloud.pubsub.spi.v1.AckReplyConsumer ;
163162import com.google.cloud.pubsub.spi.v1.MessageReceiver ;
164163import com.google.cloud.pubsub.spi.v1.Subscriber ;
@@ -175,7 +174,7 @@ MessageReceiver receiver =
175174 @Override
176175 public void receiveMessage (PubsubMessage message , AckReplyConsumer consumer ) {
177176 System . out. println(" got message: " + message. getData(). toStringUtf8());
178- consumer. accept( AckReply . ACK , null );
177+ consumer. ack( );
179178 }
180179 };
181180Subscriber subscriber = null ;
Original file line number Diff line number Diff line change 2222public interface MessageReceiver {
2323 /**
2424 * Called when a message is received by the subscriber. The implementation must arrange for {@link
25- * AckReplyConsumer#accept} to be called after processing the {@code message}.
25+ * AckReplyConsumer#ack()} or {@link
26+ * AckReplyConsumer#nack()} to be called after processing the {@code message}.
2627 *
2728 * <p>This {@code MessageReceiver} passes all messages to a {@code BlockingQueue}.
2829 * This method can be called concurrently from multiple threads,
@@ -34,9 +35,9 @@ public interface MessageReceiver {
3435 * MessageReceiver receiver = new MessageReceiver() {
3536 * public void receiveMessage(final PubsubMessage message, final AckReplyConsumer consumer) {
3637 * if (blockingQueue.offer(message)) {
37- * consumer.accept(AckReply.ACK, null );
38+ * consumer.ack( );
3839 * } else {
39- * consumer.accept(AckReply.NACK, null );
40+ * consumer.nack( );
4041 * }
4142 * }
4243 * };
Original file line number Diff line number Diff line change 5555 *
5656 * <p>A {@link Subscriber} allows you to provide an implementation of a {@link MessageReceiver
5757 * receiver} to which messages are going to be delivered as soon as they are received by the
58- * subscriber. The delivered messages then can be {@link AckReply#ACK acked} or {@link AckReply#NACK
59- * nacked} at will as they get processed by the receiver. Nacking a messages implies a later
60- * redelivery of such message.
58+ * subscriber. The delivered messages then can be {@link AckReplyConsumer#ack() acked} or {@link
59+ * AckReplyConsumer#nack() nacked} at will as they get processed by the receiver. Nacking a messages
60+ * implies a later redelivery of such message.
6161 *
6262 * <p>The subscriber handles the ack management, by automatically extending the ack deadline while
6363 * the message is being processed, to then issue the ack or nack of such message when the processing
Original file line number Diff line number Diff line change 2121
2222import com .google .api .gax .core .SettableApiFuture ;
2323import com .google .cloud .ServiceOptions ;
24- import com .google .cloud .pubsub .spi .v1 .AckReply ;
2524import com .google .cloud .pubsub .spi .v1 .AckReplyConsumer ;
2625import com .google .cloud .pubsub .spi .v1 .MessageReceiver ;
2726import com .google .cloud .pubsub .spi .v1 .Publisher ;
@@ -116,9 +115,9 @@ public void testPublishSubscribe() throws Exception {
116115 public void receiveMessage (
117116 final PubsubMessage message , final AckReplyConsumer consumer ) {
118117 if (received .set (message )) {
119- consumer .accept ( AckReply . ACK );
118+ consumer .ack ( );
120119 } else {
121- consumer .accept ( AckReply . NACK );
120+ consumer .nack ( );
122121 }
123122 }
124123 })
You can’t perform that action at this time.
0 commit comments