added delay for sqs message (#168)
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user