我使用KPL和AWS lambda(Java)来生成Kinesis流。
我添加消息的代码是这样的:
ListenableFuture<UserRecordResult> f = KP.addUserRecord(Stream, partitionKey, ByteBuffer.wrap(data.getBytes()));
Futures.addCallback(f, new FutureCallback<UserRecordResult>() {
private Logger LG = Logger.getLogger(this.getClass());
@Override
public void onSuccess(UserRecordResult result) {
LG.info("Successfully sent "+result.getSequenceNumber()+" to stream shard #"+result.getShardId());
}
@Override
public void onFailure(Throwable t) {
LG.debug("Something wrong happend while sending to stream , "+t.getMessage());
}
});
问题有时在执行Lambda
期间,生产者没有将消息提交给Kinesis。因此,如果我想强制推送消息,我必须调用方法flushSync()
,这会导致Lambda稍后出现其他错误。
我的KPL配置也是:
AggregationEnabled = true
AggregationMaxCount = 4294967295
AggregationMaxSize = 51200
CollectionMaxCount = 500
CollectionMaxSize = 5242880
ConnectTimeout = 6000
FailIfThrottled = false
MaxConnections = 24
MetricsGranularity = shard
MinConnections = 1
RateLimit = 150
RecordMaxBufferedTime = 3000
RecordTtl = 30000
RequestTimeout = 60000
VerifyCertificate = true
CredentialsRefreshDelay = 100
答案 0 :(得分:0)
这是kinesis KPL的一个已知问题,其行为与AWS中的其他服务不同。解决此问题,但尚未解决。 另外,运行flush或flushSync方法不能确保整个事务都正确编写,因为lambda可能会超时(外部关闭)。