Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | 1x 1x 1x 1x 1x 1x 1x 1x 1x | import {AWSError, SQS} from 'aws-sdk';
import {DeleteMessageRequest} from 'aws-sdk/clients/sqs';
import {Producer} from 'sqs-producer';
import {Message} from 'sqs-producer/dist/types';
import {AwsConfigs} from '../../../configs';
export class AwsSqsService {
sqs: SQS;
producer: Producer;
queueUrl: string = AwsConfigs.sqsConfig.queueUrl;
batchSize: number = AwsConfigs.sqsConfig.batchSize || 10;
region: string = AwsConfigs.region;
constructor() {
this.producer = Producer.create({
queueUrl: this.queueUrl,
batchSize: this.batchSize,
region: this.region,
});
this.sqs = new SQS({
apiVersion: '2012-11-05',
endpoint: this.queueUrl,
region: this.region,
});
}
/**
* Sends a message to aws sqs
* @param messages The message
* @returns Promise<SQS.SendMessageBatchResultEntryList>
*/
async send(messages: string | Message | (string | Message)[]): Promise<SQS.SendMessageBatchResultEntryList> {
return this.producer.send(messages);
}
/**
* Delete message in flight
* @param {DeleteMessageRequest} params
* @param {((err:AWSError,data:{})=>void)|undefined} callback
*/
deleteMessage(params: DeleteMessageRequest, callback: ((err: AWSError, data: {}) => void) | undefined) {
return this.sqs.deleteMessage(params, callback);
}
}
|