added delay for sqs message (#168)

This commit is contained in:
Arwid Thornström
2024-10-30 14:13:10 +01:00
committed by GitHub
parent 549046096c
commit 6e66c5ed7f
2 changed files with 5 additions and 0 deletions
+4
View File
@@ -8,6 +8,7 @@ import {
export async function sendMessage( export async function sendMessage(
body: string, body: string,
queueUrl: string, queueUrl: string,
delaySeconds?: number,
): Promise<SendMessageCommandOutput | undefined> { ): Promise<SendMessageCommandOutput | undefined> {
const client = new SQSClient({ region: 'eu-west-1' }); const client = new SQSClient({ region: 'eu-west-1' });
@@ -15,6 +16,9 @@ export async function sendMessage(
MessageBody: body, MessageBody: body,
QueueUrl: queueUrl, QueueUrl: queueUrl,
}; };
if (delaySeconds) {
params.DelaySeconds = delaySeconds;
}
const sendMessageCommand = new SendMessageCommand(params); const sendMessageCommand = new SendMessageCommand(params);
return client.send(sendMessageCommand); return client.send(sendMessageCommand);
+1
View File
@@ -231,6 +231,7 @@ export const productMutationTypeDefs = {
await sendMessage( await sendMessage(
JSON.stringify({ productId: id, artNo: product.fields.artNo }), JSON.stringify({ productId: id, artNo: product.fields.artNo }),
process.env.SAMPLE_SQS_QUEUE_URL, process.env.SAMPLE_SQS_QUEUE_URL,
60 * 10,
); );
return product; return product;