Search in sources :

Example 6 with AcknowledgeRequest

use of com.google.pubsub.v1.AcknowledgeRequest in project flink by apache.

the class PubsubHelper method acknowledgeIds.

private void acknowledgeIds(SubscriberStub subscriber, String subscriptionName, List<ReceivedMessage> receivedMessages) {
    if (receivedMessages.isEmpty()) {
        return;
    }
    List<String> ackIds = receivedMessages.stream().map(ReceivedMessage::getAckId).collect(Collectors.toList());
    // acknowledge received messages
    AcknowledgeRequest acknowledgeRequest = AcknowledgeRequest.newBuilder().setSubscription(subscriptionName).addAllAckIds(ackIds).build();
    // use acknowledgeCallable().futureCall to asynchronously perform this operation
    subscriber.acknowledgeCallable().call(acknowledgeRequest);
}
Also used : AcknowledgeRequest(com.google.pubsub.v1.AcknowledgeRequest)

Aggregations

AcknowledgeRequest (com.google.pubsub.v1.AcknowledgeRequest)6 ByteString (com.google.protobuf.ByteString)2 SubscriberStub (com.google.cloud.pubsub.v1.stub.SubscriberStub)1 Empty (com.google.protobuf.Empty)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1 PullResponse (com.google.pubsub.v1.PullResponse)1 SubscriptionName (com.google.pubsub.v1.SubscriptionName)1 ArrayList (java.util.ArrayList)1 Collections.emptyList (java.util.Collections.emptyList)1 List (java.util.List)1 Test (org.junit.Test)1