@nsshunt/stsappframework 2.19.250 → 2.19.251
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/runkafka.sh +1 -1
- package/runkafkaconsume.sh +0 -24
- package/src/kafkatesting/consume.js +0 -87
- package/src/kafkatesting/produce.js +0 -88
package/package.json
CHANGED
package/runkafka.sh
CHANGED
package/runkafkaconsume.sh
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
# openssl req -nodes -new -x509 -keyout server.key -out server.cert
|
|
3
|
-
clear; \
|
|
4
|
-
export STS_PROJ_ROOT=./..; \
|
|
5
|
-
STSENVFILE=$STS_PROJ_ROOT/stsglobalresources/.env \
|
|
6
|
-
DB_SCRIPT_FOLDER=$STS_PROJ_ROOT/stsglobalresources/db-scripts \
|
|
7
|
-
REST01_PORT=3003 \
|
|
8
|
-
REST01_HOST_PORT=3003 \
|
|
9
|
-
REST01_SERVICE_NAME="STSRest01-3003" \
|
|
10
|
-
REST01_API_IDENTIFIER="https://stsmda.com.au/stsrest01api/v1.0/" \
|
|
11
|
-
REST01_ENDPOINT="https://stsrest.stsmda.org" \
|
|
12
|
-
MAX_CPU=1 \
|
|
13
|
-
AS_ENDPOINT=https://stscore.stsmda.org \
|
|
14
|
-
AS_HOST_PORT=3002 \
|
|
15
|
-
AS_PORT=3002 \
|
|
16
|
-
DB_HOST=localhost \
|
|
17
|
-
DB_PORT=5432 \
|
|
18
|
-
DB_PASSWORD=postgres \
|
|
19
|
-
HTTPS_SERVER_KEY_PATH=/etc/letsencrypt/live/stsmda.org/privkey.pem \
|
|
20
|
-
HTTPS_SERVER_CERT_PATH=/etc/letsencrypt/live/stsmda.org/fullchain.pem \
|
|
21
|
-
DEBUG=proc* \
|
|
22
|
-
PUBLISH_DEBUG=false \
|
|
23
|
-
UV_THREADPOOL_SIZE=64 \
|
|
24
|
-
node ./src/kafkatesting/consume.js
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/* eslint @typescript-eslint/no-unused-vars: 0 */ // --> OFF
|
|
2
|
-
import { Kafka } from 'kafkajs'
|
|
3
|
-
|
|
4
|
-
async function Sleep(milliseconds = 1000) {
|
|
5
|
-
return new Promise(resolve => setTimeout(resolve, milliseconds))
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const kafka = new Kafka({
|
|
9
|
-
clientId: 'my-app',
|
|
10
|
-
brokers: ['192.168.14.92:9092']
|
|
11
|
-
//brokers: ['localhost:9092', 'kafka2:9092'],
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
const consumer = kafka.consumer({ groupId: 'my-group' })
|
|
15
|
-
|
|
16
|
-
const runme = async () => {
|
|
17
|
-
|
|
18
|
-
await consumer.connect()
|
|
19
|
-
|
|
20
|
-
await consumer.subscribe({ topics: ['topic-name2'], fromBeginning: true })
|
|
21
|
-
|
|
22
|
-
console.log('--------------------------------------------')
|
|
23
|
-
|
|
24
|
-
await consumer.run({
|
|
25
|
-
eachMessage: async ({ topic, partition, message, heartbeat, pause }) => {
|
|
26
|
-
try {
|
|
27
|
-
console.log({
|
|
28
|
-
key: message.key.toString(),
|
|
29
|
-
partition: partition.toString(),
|
|
30
|
-
value: message.value.toString(),
|
|
31
|
-
headers: message.headers,
|
|
32
|
-
})
|
|
33
|
-
} catch (err) {
|
|
34
|
-
console.log(err);
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
console.log('=================================================')
|
|
40
|
-
|
|
41
|
-
/*
|
|
42
|
-
process.on("SIGINT", async () => {
|
|
43
|
-
console.log('=========SIGTERM START =======================')
|
|
44
|
-
await consumer.disconnect()
|
|
45
|
-
console.log('=========SIGTERM END =======================')
|
|
46
|
-
process.exit();
|
|
47
|
-
});
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
let iteration = 0;
|
|
51
|
-
for (;;) {
|
|
52
|
-
console.log('sleep: ' + iteration++);
|
|
53
|
-
await Sleep(1000);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const errorTypes = ['unhandledRejection', 'uncaughtException']
|
|
58
|
-
const signalTraps = ['SIGTERM', 'SIGINT', 'SIGUSR2']
|
|
59
|
-
|
|
60
|
-
errorTypes.forEach(type => {
|
|
61
|
-
process.on(type, async () => {
|
|
62
|
-
try {
|
|
63
|
-
console.log(`process.on ${type}`)
|
|
64
|
-
console.log('=========consumer.disconnect() START =======================')
|
|
65
|
-
await consumer.disconnect()
|
|
66
|
-
console.log('=========consumer.disconnect() END =======================')
|
|
67
|
-
process.exit(0)
|
|
68
|
-
} catch (_) {
|
|
69
|
-
process.exit(1)
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
signalTraps.forEach(type => {
|
|
75
|
-
process.once(type, async () => {
|
|
76
|
-
try {
|
|
77
|
-
console.log('=========consumer.disconnect() START [2] =======================')
|
|
78
|
-
await consumer.disconnect()
|
|
79
|
-
console.log('=========consumer.disconnect() END [2] =======================')
|
|
80
|
-
} finally {
|
|
81
|
-
process.kill(process.pid, type)
|
|
82
|
-
}
|
|
83
|
-
})
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
runme().catch(e => console.error(`[example/producer] ${e.message}`, e))
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { Kafka } from 'kafkajs'
|
|
2
|
-
|
|
3
|
-
async function Sleep(milliseconds = 1000) {
|
|
4
|
-
return new Promise(resolve => setTimeout(resolve, milliseconds))
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const kafka = new Kafka({
|
|
8
|
-
clientId: 'my-app',
|
|
9
|
-
brokers: ['192.168.14.92:9092']
|
|
10
|
-
//brokers: ['localhost:9092', 'kafka2:9092'],
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
const runme = async () => {
|
|
14
|
-
const producer = kafka.producer()
|
|
15
|
-
await producer.connect()
|
|
16
|
-
|
|
17
|
-
const count = 100000;
|
|
18
|
-
const sleepTime = 0;
|
|
19
|
-
|
|
20
|
-
process.on("SIGINT", async () => {
|
|
21
|
-
console.log('=========SIGTERM START =======================')
|
|
22
|
-
await producer.disconnect()
|
|
23
|
-
console.log('=========SIGTERM END =======================')
|
|
24
|
-
process.exit();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
for (let i=0; i < count; i++) {
|
|
28
|
-
if (i % 100 === 0) console.log(i);
|
|
29
|
-
let retVal = await producer.send({
|
|
30
|
-
topic: 'topic-name2',
|
|
31
|
-
messages: [
|
|
32
|
-
/*
|
|
33
|
-
{ key: 'key1', value: `hello world - ${i}`, partition: 0 },
|
|
34
|
-
{ key: 'key2', value: 'hey hey!', partition: 1 },
|
|
35
|
-
{ key: 'key3', value: 'hey hey!', partition: 2 }
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
{ key: 'key1', value: `hello world - ${i}` },
|
|
39
|
-
{ key: 'key2', value: 'hey hey! -2' },
|
|
40
|
-
{ key: 'key3', value: 'hey hey! -3' },
|
|
41
|
-
{ key: 'key4', value: 'hey hey! -4' },
|
|
42
|
-
{ key: 'key5', value: 'hey hey! -5' },
|
|
43
|
-
|
|
44
|
-
//{ value: 'val3' },
|
|
45
|
-
//{ key: 'key4', value: 'val 4', partition: 1 },
|
|
46
|
-
],
|
|
47
|
-
})
|
|
48
|
-
if (i % 100 === 0) {
|
|
49
|
-
//console.log(retVal[0].baseOffset);
|
|
50
|
-
console.log(retVal);
|
|
51
|
-
}
|
|
52
|
-
if (sleepTime >= 0) {
|
|
53
|
-
await Sleep(sleepTime);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
await producer.disconnect()
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/*
|
|
61
|
-
const errorTypes = ['unhandledRejection', 'uncaughtException']
|
|
62
|
-
const signalTraps = ['SIGTERM', 'SIGINT', 'SIGUSR2']
|
|
63
|
-
|
|
64
|
-
errorTypes.forEach(type => {
|
|
65
|
-
process.on(type, async () => {
|
|
66
|
-
try {
|
|
67
|
-
console.log(`process.on ${type}`)
|
|
68
|
-
await producer.disconnect()
|
|
69
|
-
process.exit(0)
|
|
70
|
-
} catch (_) {
|
|
71
|
-
process.exit(1)
|
|
72
|
-
}
|
|
73
|
-
})
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
signalTraps.forEach(type => {
|
|
77
|
-
process.once(type, async () => {
|
|
78
|
-
try {
|
|
79
|
-
await producer.disconnect()
|
|
80
|
-
} finally {
|
|
81
|
-
process.kill(process.pid, type)
|
|
82
|
-
}
|
|
83
|
-
})
|
|
84
|
-
})
|
|
85
|
-
*/
|
|
86
|
-
|
|
87
|
-
runme().catch(e => console.error(`[example/producer] ${e.message}`, e))
|
|
88
|
-
|