The scenario is the following: 1 topic and 1 subscription with default ack deadline (10 seconds). I publish 2 messages (message1 and message2) to the topic and then pull messages from the subscription.
After the first pull I set the ack deadline of message1 to a big value (let's say 100 seconds). Then I pull messages from the subscription every 20 seconds. The expected behavior is that pulls return only message2 until ~100 seconds are passed, and then return both message1 and message2.
When I run this scenario against the actual service I get the weird behavior: pull requests made before that ~100 seconds are passed after the deadline modification return no messages (as if both messages where affected by modifyAckDeadline).
The veneer toolkit code that reproduces the error is the following:
PublisherApipublisher = PublisherApi.create(publisherSettings);
SubscriberApisubscriber = SubscriberApi.create(subscriberSettings);
StringtopicName = PublisherApi.formatTopicName("gcloud-devel", "test-topic");
StringsubscriptionName =
SubscriberApi.formatSubscriptionName("gcloud-devel", "test-subscription");
publisher.createTopic(topicName);
subscriber.createSubscription(Subscription.newBuilder()
.setName(subscriptionName)
.setTopic(topicName)
.setAckDeadlineSeconds(10)
.build());
publisher.publish(topicName, ImmutableList.of(
PubsubMessage.newBuilder().setData(ByteString.copyFromUtf8("message1")).build(),
PubsubMessage.newBuilder().setData(ByteString.copyFromUtf8("message2")).build()));
PullResponsepullResponse = subscriber.pull(subscriptionName, true, 2);
List<ReceivedMessage> receivedMessages = pullResponse.getReceivedMessagesList();
for (ReceivedMessagemessage : pullResponse.getReceivedMessagesList()) {
System.out.printf("[%d][PULLED MESSAGE %s]%n",
System.currentTimeMillis(), message.getMessage().getData().toStringUtf8());
}
// Set the deadline of the first message far awaysubscriber.modifyAckDeadline(subscriptionName,
ImmutableList.of(receivedMessages.get(0).getAckId()), 100);
// Second message should be again available for pulling after .sleep()Thread.sleep(20000);
for (inti = 0; i < 10; i++) {
pullResponse = subscriber.pull(subscriptionName, true, 2);
receivedMessages = pullResponse.getReceivedMessagesList();
if (receivedMessages.isEmpty()) {
System.out.printf("[%d][PULLED NO MESSAGES]%n", System.currentTimeMillis());
} else {
for (ReceivedMessagemessage : pullResponse.getReceivedMessagesList()) {
System.out.printf("[%d][PULLED MESSAGE %s]%n",
System.currentTimeMillis(), message.getMessage().getData().toStringUtf8());
}
}
Thread.sleep(20000);
}
publisher.deleteTopic(topicName);
subscriber.deleteSubscription(subscriptionName);When I run it against the actual service I get the following output:
[1463750536877][PULLEDMESSAGEmessage1]
[1463750536877][PULLEDMESSAGEmessage2]
[1463750561558][PULLEDNOMESSAGES] // <-- here and in the following I would expect message2
[1463750584638][PULLEDNOMESSAGES]
[1463750608178][PULLEDNOMESSAGES]
[1463750631240][PULLEDNOMESSAGES]
[1463750653656][PULLEDMESSAGEmessage1]
[1463750653657][PULLEDMESSAGEmessage2]
[1463750676241][PULLEDMESSAGEmessage1]
[1463750676241][PULLEDMESSAGEmessage2]
[1463750698302][PULLEDMESSAGEmessage1]
[1463750698302][PULLEDMESSAGEmessage2]
[1463750720269][PULLEDMESSAGEmessage1]
[1463750720270][PULLEDMESSAGEmessage2]
[1463750742847][PULLEDMESSAGEmessage1]
[1463750742847][PULLEDMESSAGEmessage2]
Instead when I run it agains the emulator the output is as expected:
[1463749875238][PULLEDMESSAGEmessage1]
[1463749875238][PULLEDMESSAGEmessage2]
[1463749895270][PULLEDMESSAGEmessage2]
[1463749915289][PULLEDMESSAGEmessage2]
[1463749935308][PULLEDMESSAGEmessage2]
[1463749955329][PULLEDMESSAGEmessage2]
[1463749975347][PULLEDMESSAGEmessage1]
[1463749975347][PULLEDMESSAGEmessage2]
[1463749995363][PULLEDMESSAGEmessage1]
[1463749995363][PULLEDMESSAGEmessage2]
[1463750015384][PULLEDMESSAGEmessage2]
[1463750015384][PULLEDMESSAGEmessage1]
[1463750035403][PULLEDMESSAGEmessage2]
[1463750035403][PULLEDMESSAGEmessage1]
[1463750055421][PULLEDMESSAGEmessage2]
[1463750055422][PULLEDMESSAGEmessage1]
@eschapira@garrettjonesgoogle Any idea about what's going on?
The scenario is the following: 1 topic and 1 subscription with default ack deadline (10 seconds). I publish 2 messages (
message1andmessage2) to the topic and then pull messages from the subscription.After the first pull I set the ack deadline of
message1to a big value (let's say 100 seconds). Then I pull messages from the subscription every 20 seconds. The expected behavior is that pulls return onlymessage2until ~100 seconds are passed, and then return bothmessage1andmessage2.When I run this scenario against the actual service I get the weird behavior: pull requests made before that ~100 seconds are passed after the deadline modification return no messages (as if both messages where affected by
modifyAckDeadline).The veneer toolkit code that reproduces the error is the following:
When I run it against the actual service I get the following output:
Instead when I run it agains the emulator the output is as expected:
@eschapira@garrettjonesgoogle Any idea about what's going on?