I have a weird problem when fetching items from kinesis.
So when I have events in the stream, and Im querying for them with the correct timestamp, I get the result.
But if I don't have events in the stream
or
if I'm querying for times where not event are there
The call getShardIterator gets stuck for several minutes.
That's why I added the "timeout" of 2 seconds.
Is there a better way to just get an empty response from kinesis if no events found?
Thanks
<?php
$getKinessisClient = new GetKinessisClient();
$kinesisClient = $getKinessisClient->get([
]);
$params = [
'credentials' => array(
'key' => 'xxxx',
'secret' => 'xxxx',
),
'region' => 'xxxx',
'version' => 'latest',
'http' => [
'timeout' => 2
]
];
$kinesisClient = (new Sdk())->createKinesis($params);
// get all shard ids
$res = $kinesisClient->describeStream([ 'StreamName' => $streamName ]);
$shardIds = $res->search('StreamDescription.Shards[].ShardId');
$foundItems = [];
foreach ($shardIds as $shardId) {
try {
$getShardItParams = [
'ShardId' => $shardId,
'StreamName' => $streamName,
'ShardIteratorType' => 'AT_TIMESTAMP',
'Timestamp' => $from_timestamp, //PROBLEM HERE
];
// this gets stuck (without timeout)
$res = $kinesisClient->getShardIterator($getShardItParams);