-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrepl.ts
54 lines (47 loc) · 1.24 KB
/
repl.ts
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
46
47
48
49
50
51
52
53
54
#!/usr/bin/env ts-node-script
/**
* @file Exports the logger interface.
*/
/* eslint-disable no-console */
/* eslint-disable no-new */
import { SQSConsumer } from './index';
/**
* This script acts as a consumer for the code in this repository.
* Only imports from index.ts file are allowed here: no other files
* should be imported directly. To run this script: use ./node_modules/.bin/ts-node repl.ts.
*/
type TestMessageType = {
orderId: string;
handle: string;
};
/**
* Provides sample usage of the sqs consumer.
*/
async function testSQSConsumer(): Promise<void> {
const tsSQSConsumer: SQSConsumer<TestMessageType> = new SQSConsumer({
sqsOptions: {
clientOptions: {
region: 'region-that-does-not-exist',
},
receiveMessageOptions: {
queueUrl: 'url-of-your-queue',
visibilityTimeout: 1800,
waitTimeSeconds: 20,
maxNumberOfMessages: 1,
stopAtFirstError: false,
},
},
jobProcessorOptions: {
jobProcessor: (async (message: TestMessageType) => {
console.log('Got message');
console.log(message);
}),
},
});
await tsSQSConsumer
.processPendingJobs()
.catch((err: Error): void => {
throw err;
});
}
testSQSConsumer();