You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to test/debug an issue in an sqs triggered function and tried to exit the script early with exit like what's below. What's odd is that rather than exiting the script, it gets stuck in an infinite loop (I see "SQS Handler Entered" and then the log of the message Id and receive count loop again and again and again). messageReceivedCount is always 1 and from what I can tell this is a single execution of the function (eg: not triggering lambda multiple times).
I'm curious why it's doing that and if there is a better way to exit a function early in an sqs triggered function?
class Handler extends SqsHandler
{
public function handleSqs(SqsEvent $event, Context $context): void
{
Logger::warn("SQS Handler entered");
foreach ($event->getRecords() as $record) {
// We can retrieve the message body of each record via `->getBody()`
Logger::warn('SQS Message Id: ' . $record->getMessageId() . ' Approx ReceiveCount: ' . $record->getApproximateReceiveCount());
exit;
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I was trying to test/debug an issue in an sqs triggered function and tried to exit the script early with exit like what's below. What's odd is that rather than exiting the script, it gets stuck in an infinite loop (I see "SQS Handler Entered" and then the log of the message Id and receive count loop again and again and again). messageReceivedCount is always 1 and from what I can tell this is a single execution of the function (eg: not triggering lambda multiple times).
I'm curious why it's doing that and if there is a better way to exit a function early in an sqs triggered function?
class Handler extends SqsHandler
{
public function handleSqs(SqsEvent $event, Context $context): void
{
}
Beta Was this translation helpful? Give feedback.
All reactions