added delay for sqs message (#168)
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
export async function sendMessage(
|
||||
body: string,
|
||||
queueUrl: string,
|
||||
delaySeconds?: number,
|
||||
): Promise<SendMessageCommandOutput | undefined> {
|
||||
const client = new SQSClient({ region: 'eu-west-1' });
|
||||
|
||||
@@ -15,6 +16,9 @@ export async function sendMessage(
|
||||
MessageBody: body,
|
||||
QueueUrl: queueUrl,
|
||||
};
|
||||
if (delaySeconds) {
|
||||
params.DelaySeconds = delaySeconds;
|
||||
}
|
||||
const sendMessageCommand = new SendMessageCommand(params);
|
||||
|
||||
return client.send(sendMessageCommand);
|
||||
|
||||
@@ -231,6 +231,7 @@ export const productMutationTypeDefs = {
|
||||
await sendMessage(
|
||||
JSON.stringify({ productId: id, artNo: product.fields.artNo }),
|
||||
process.env.SAMPLE_SQS_QUEUE_URL,
|
||||
60 * 10,
|
||||
);
|
||||
|
||||
return product;
|
||||
|
||||
Reference in New Issue
Block a user