Skip to content

Instantly share code, notes, and snippets.

@richardgrantserverless
Created April 7, 2022 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richardgrantserverless/a0527ae8799f9400a8582505ce7b3b1f to your computer and use it in GitHub Desktop.
Save richardgrantserverless/a0527ae8799f9400a8582505ce7b3b1f to your computer and use it in GitHub Desktop.
# worker.js
exports.handler = async function(event) {  
const failedMessageIds = [];  
event.Records.forEach(record => {    
try {      
const bodyData = JSON.parse(record.body);      
console.log(`Processing ${record.messageId}`);      
// ...    
} catch (e) {      
failedMessageIds.push(record.messageId);    
}  
});
return {    
batchItemFailures: failedMessageIds.map(id => {      
return {        
itemIdentifier: id      
}    
})  
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment