software.amazon.kinesis.retrieval.RetrievalConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of amazon-kinesis-client Show documentation
Show all versions of amazon-kinesis-client Show documentation
The Amazon Kinesis Client Library for Java enables Java developers to easily consume and process data
from Amazon Kinesis.
/*
* Copyright 2019 Amazon.com, Inc. or its affiliates.
* Licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package software.amazon.kinesis.retrieval;
import lombok.Data;
import lombok.NonNull;
import lombok.experimental.Accessors;
import software.amazon.awssdk.services.kinesis.KinesisAsyncClient;
import software.amazon.kinesis.common.InitialPositionInStream;
import software.amazon.kinesis.common.InitialPositionInStreamExtended;
import software.amazon.kinesis.retrieval.fanout.FanOutConfig;
/**
* Used by the KCL to configure the retrieval of records from Kinesis.
*/
@Data
@Accessors(fluent = true)
public class RetrievalConfig {
/**
* User agent set when Amazon Kinesis Client Library makes AWS requests.
*/
public static final String KINESIS_CLIENT_LIB_USER_AGENT = "amazon-kinesis-client-library-java";
public static final String KINESIS_CLIENT_LIB_USER_AGENT_VERSION = "2.2.7";
/**
* Client used to make calls to Kinesis for records retrieval
*/
@NonNull
private final KinesisAsyncClient kinesisClient;
/**
* The name of the stream to process records from.
*/
@NonNull
private final String streamName;
@NonNull
private final String applicationName;
/**
* Backoff time between consecutive ListShards calls.
*
*
* Default value: 1500L
*
*/
private long listShardsBackoffTimeInMillis = 1500L;
/**
* Max number of retries for ListShards when throttled/exception is thrown.
*
*
* Default value: 50
*
*/
private int maxListShardsRetryAttempts = 50;
/**
* The location in the shard from which the KinesisClientLibrary will start fetching records from
* when the application starts for the first time and there is no checkpoint for the shard.
*
*
* Default value: {@link InitialPositionInStream#LATEST}
*
*/
private InitialPositionInStreamExtended initialPositionInStreamExtended = InitialPositionInStreamExtended
.newInitialPosition(InitialPositionInStream.LATEST);
private RetrievalSpecificConfig retrievalSpecificConfig;
private RetrievalFactory retrievalFactory;
public RetrievalFactory retrievalFactory() {
if (retrievalFactory == null) {
if (retrievalSpecificConfig == null) {
retrievalSpecificConfig = new FanOutConfig(kinesisClient()).streamName(streamName())
.applicationName(applicationName());
}
retrievalFactory = retrievalSpecificConfig.retrievalFactory();
}
return retrievalFactory;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy