use of software.amazon.awssdk.services.kinesis.model.StartingPosition in project flink by apache.
the class FanOutShardSubscriberTest method testInterruptedErrorThrownToConsumer.
@Test
public void testInterruptedErrorThrownToConsumer() throws Exception {
thrown.expect(FanOutShardSubscriber.FanOutSubscriberInterruptedException.class);
SdkInterruptedException error = new SdkInterruptedException(null);
SubscriptionErrorKinesisV2 errorKinesisV2 = FakeKinesisFanOutBehavioursFactory.errorDuringSubscription(error);
FanOutShardSubscriber subscriber = new FanOutShardSubscriber("consumerArn", "shardId", errorKinesisV2, DEFAULT_SUBSCRIBE_TO_SHARD_TIMEOUT);
software.amazon.awssdk.services.kinesis.model.StartingPosition startingPosition = software.amazon.awssdk.services.kinesis.model.StartingPosition.builder().build();
subscriber.subscribeToShardAndConsumeRecords(startingPosition, event -> {
});
}
use of software.amazon.awssdk.services.kinesis.model.StartingPosition in project flink by apache.
the class FanOutShardSubscriberTest method testRetryableErrorThrownToConsumer.
@Test
public void testRetryableErrorThrownToConsumer() throws Exception {
thrown.expect(FanOutShardSubscriber.RetryableFanOutSubscriberException.class);
thrown.expectMessage("Error!");
RuntimeException error = new RuntimeException("Error!");
SubscriptionErrorKinesisV2 errorKinesisV2 = FakeKinesisFanOutBehavioursFactory.errorDuringSubscription(error);
FanOutShardSubscriber subscriber = new FanOutShardSubscriber("consumerArn", "shardId", errorKinesisV2, DEFAULT_SUBSCRIBE_TO_SHARD_TIMEOUT);
software.amazon.awssdk.services.kinesis.model.StartingPosition startingPosition = software.amazon.awssdk.services.kinesis.model.StartingPosition.builder().build();
subscriber.subscribeToShardAndConsumeRecords(startingPosition, event -> {
});
}
use of software.amazon.awssdk.services.kinesis.model.StartingPosition in project flink by apache.
the class FanOutShardSubscriberTest method testRecoverableErrorThrownToConsumer.
@Test
public void testRecoverableErrorThrownToConsumer() throws Exception {
thrown.expect(FanOutShardSubscriber.RecoverableFanOutSubscriberException.class);
thrown.expectMessage("io.netty.handler.timeout.ReadTimeoutException");
SubscriptionErrorKinesisV2 errorKinesisV2 = FakeKinesisFanOutBehavioursFactory.errorDuringSubscription(ReadTimeoutException.INSTANCE);
FanOutShardSubscriber subscriber = new FanOutShardSubscriber("consumerArn", "shardId", errorKinesisV2, DEFAULT_SUBSCRIBE_TO_SHARD_TIMEOUT);
software.amazon.awssdk.services.kinesis.model.StartingPosition startingPosition = software.amazon.awssdk.services.kinesis.model.StartingPosition.builder().build();
subscriber.subscribeToShardAndConsumeRecords(startingPosition, event -> {
});
}
use of software.amazon.awssdk.services.kinesis.model.StartingPosition in project flink by apache.
the class ShardConsumerFanOutTest method testBoundedShardConsumesFromTimestamp.
@Test
public void testBoundedShardConsumesFromTimestamp() throws Exception {
String format = "yyyy-MM-dd'T'HH:mm";
String timestamp = "2020-07-02T09:14";
Instant expectedTimestamp = new SimpleDateFormat(format).parse(timestamp).toInstant();
SingleShardFanOutKinesisV2 kinesis = FakeKinesisFanOutBehavioursFactory.boundedShard().build();
Properties consumerConfig = efoProperties();
consumerConfig.setProperty(STREAM_INITIAL_TIMESTAMP, timestamp);
consumerConfig.setProperty(STREAM_TIMESTAMP_DATE_FORMAT, format);
SequenceNumber sequenceNumber = SENTINEL_AT_TIMESTAMP_SEQUENCE_NUM.get();
// Fake behaviour defaults to 10 messages
assertNumberOfMessagesReceivedFromKinesis(10, kinesis, sequenceNumber, consumerConfig);
StartingPosition actual = kinesis.getStartingPositionForSubscription(0);
assertEquals(AT_TIMESTAMP, actual.type());
assertEquals(expectedTimestamp, actual.timestamp());
}
use of software.amazon.awssdk.services.kinesis.model.StartingPosition in project flink by apache.
the class ShardConsumerFanOutTest method testStartFromLatestIsTranslatedToTimestamp.
@Test
public void testStartFromLatestIsTranslatedToTimestamp() throws Exception {
Instant now = Instant.now();
SingleShardFanOutKinesisV2 kinesis = FakeKinesisFanOutBehavioursFactory.boundedShard().build();
SequenceNumber sequenceNumber = SENTINEL_LATEST_SEQUENCE_NUM.get();
// Fake behaviour defaults to 10 messages
assertNumberOfMessagesReceivedFromKinesis(10, kinesis, sequenceNumber, efoProperties());
StartingPosition actual = kinesis.getStartingPositionForSubscription(0);
assertEquals(AT_TIMESTAMP, actual.type());
// Considering milliseconds to make now have the same precision as actual
assertTrue(now.toEpochMilli() <= actual.timestamp().toEpochMilli());
}
Aggregations