GH-210: Short-circuit Kinesis consumer for stop

Fixes https://github.com/spring-projects/spring-integration-aws/issues/210

To avoid extra cycles for tasks and locks renewal check for a closed shard
just after `getShardIterator()` request in a `NEW` consumer task

**Cherry-pick to `2.5.x`**
This commit is contained in:
abilan
2022-11-30 11:28:46 -05:00
parent f5b31d2495
commit 2eb0ba2c3f

View File

@@ -974,6 +974,10 @@ public class KinesisMessageDrivenChannelAdapter extends MessageProducerSupport
.amazonKinesis
.getShardIterator(shardIteratorRequest)
.getShardIterator();
if (this.shardIterator == null) {
// The shard is closed - stop consumer
this.state = ConsumerState.STOP;
}
if (ConsumerState.STOP != this.state) {
this.state = ConsumerState.CONSUME;
}