pulsar-client 1.13.2 → 1.14.0-rc.1
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/.idea/aws.xml +18 -0
- package/.idea/codeStyles/Project.xml +7 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/misc.xml +7 -0
- package/.idea/modules.xml +9 -0
- package/.idea/pulsar-client-node.iml +46 -0
- package/.idea/pulsar_client_node.iml +8 -0
- package/.idea/vcs.xml +6 -0
- package/index.d.ts +17 -0
- package/package.json +1 -1
- package/src/Client.cc +2 -1
- package/src/Client.h +1 -0
- package/src/ConsumerConfig.cc +66 -0
- package/src/cert.pem +3278 -0
- package/.clang-format +0 -26
- package/.eslintignore +0 -21
- package/.eslintrc.json +0 -22
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -85
- package/.github/workflows/ci-build-release-napi.yml +0 -211
- package/.github/workflows/ci-pr-validation.yml +0 -334
- package/build-support/download-release-artifacts.py +0 -77
- package/build-support/generate-source-archive.sh +0 -28
- package/build-support/pulsar-test-container-start.sh +0 -43
- package/build-support/pulsar-test-service-start.sh +0 -39
- package/build-support/pulsar-test-service-stop.sh +0 -32
- package/build-support/sign-files.sh +0 -32
- package/build-support/stage-release.sh +0 -44
- package/docs/release-process.md +0 -291
- package/examples/certificate/private-key.client-rsa.pem +0 -27
- package/examples/certificate/public-key.client-rsa.pem +0 -9
- package/examples/consumer-schema.js +0 -66
- package/examples/consumer.js +0 -46
- package/examples/consumer_listener.js +0 -44
- package/examples/consumer_tls_auth.js +0 -51
- package/examples/consummer_token_auth.js +0 -50
- package/examples/consummer_token_auth_supplier.js +0 -56
- package/examples/custom_logger.js +0 -60
- package/examples/encryption-consumer.js +0 -47
- package/examples/encryption-producer.js +0 -50
- package/examples/encryption-reader.js +0 -44
- package/examples/producer-schema.js +0 -76
- package/examples/producer.js +0 -48
- package/examples/producer_tls_auth.js +0 -52
- package/examples/producer_token_auth.js +0 -48
- package/examples/producer_token_auth_supplier.js +0 -53
- package/examples/reader.js +0 -43
- package/examples/reader_listener.js +0 -37
- package/license-checker-config.json +0 -43
- package/license-header.txt +0 -16
- package/perf/perf_consumer.js +0 -103
- package/perf/perf_producer.js +0 -118
- package/pkg/linux/Dockerfile_linux_glibc +0 -31
- package/pkg/linux/Dockerfile_linux_musl +0 -32
- package/pkg/linux/build-napi-inside-docker.sh +0 -31
- package/pkg/linux/download-cpp-client.sh +0 -65
- package/pkg/load_test.js +0 -34
- package/pkg/mac/download-cpp-client.sh +0 -36
- package/pkg/windows/download-cpp-client.bat +0 -12
- package/tests/certificate/private-key.client-rsa.pem +0 -27
- package/tests/certificate/public-key.client-rsa.pem +0 -9
- package/tests/certificate/server.crt +0 -20
- package/tests/certificate/server.key +0 -28
- package/tests/client.test.js +0 -122
- package/tests/conf/standalone.conf +0 -308
- package/tests/consumer.test.js +0 -434
- package/tests/docker-load-test.sh +0 -35
- package/tests/end_to_end.test.js +0 -1447
- package/tests/http_utils.js +0 -45
- package/tests/load-test.sh +0 -43
- package/tests/producer.test.js +0 -160
- package/tests/reader.test.js +0 -175
- package/tests/run-unit-tests.sh +0 -35
- package/tsconfig.json +0 -22
- package/tslint.json +0 -9
- package/tstest.ts +0 -408
- package/typedoc.json +0 -15
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const Pulsar = require('../');
|
|
21
|
-
|
|
22
|
-
(async () => {
|
|
23
|
-
// Create a client
|
|
24
|
-
const client = new Pulsar.Client({
|
|
25
|
-
serviceUrl: 'pulsar://localhost:6650',
|
|
26
|
-
operationTimeoutSeconds: 30,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const schemaInfo = {
|
|
30
|
-
schemaType: "Json",
|
|
31
|
-
schema: JSON.stringify({
|
|
32
|
-
type: 'record',
|
|
33
|
-
name: 'Example',
|
|
34
|
-
namespace: 'test',
|
|
35
|
-
fields: [
|
|
36
|
-
{
|
|
37
|
-
name: 'a',
|
|
38
|
-
type: 'int',
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
name: 'b',
|
|
42
|
-
type: 'int',
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
}),
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// Create a consumer
|
|
49
|
-
const consumer = await client.subscribe({
|
|
50
|
-
topic: 'persistent://public/default/schema-test',
|
|
51
|
-
subscription: 'sub1',
|
|
52
|
-
subscriptionType: 'Shared',
|
|
53
|
-
ackTimeoutMs: 10000,
|
|
54
|
-
schema: schemaInfo,
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// Receive messages
|
|
58
|
-
for (let i = 0; i < 10; i += 1) {
|
|
59
|
-
const msg = await consumer.receive();
|
|
60
|
-
console.log(msg.getData().toString());
|
|
61
|
-
consumer.acknowledge(msg);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
await consumer.close();
|
|
65
|
-
await client.close();
|
|
66
|
-
})();
|
package/examples/consumer.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const Pulsar = require('../');
|
|
21
|
-
|
|
22
|
-
(async () => {
|
|
23
|
-
// Create a client
|
|
24
|
-
const client = new Pulsar.Client({
|
|
25
|
-
serviceUrl: 'pulsar://localhost:6650',
|
|
26
|
-
operationTimeoutSeconds: 30,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
// Create a consumer
|
|
30
|
-
const consumer = await client.subscribe({
|
|
31
|
-
topic: 'persistent://public/default/my-topic',
|
|
32
|
-
subscription: 'sub1',
|
|
33
|
-
subscriptionType: 'Shared',
|
|
34
|
-
ackTimeoutMs: 10000,
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// Receive messages
|
|
38
|
-
for (let i = 0; i < 10; i += 1) {
|
|
39
|
-
const msg = await consumer.receive();
|
|
40
|
-
console.log(msg.getData().toString());
|
|
41
|
-
consumer.acknowledge(msg);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
await consumer.close();
|
|
45
|
-
await client.close();
|
|
46
|
-
})();
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const Pulsar = require('../');
|
|
21
|
-
|
|
22
|
-
// It will be released and disconnected when there are no references,
|
|
23
|
-
// so declare it with let.
|
|
24
|
-
let client;
|
|
25
|
-
|
|
26
|
-
(async () => {
|
|
27
|
-
// Create a client
|
|
28
|
-
client = new Pulsar.Client({
|
|
29
|
-
serviceUrl: 'pulsar://localhost:6650',
|
|
30
|
-
operationTimeoutSeconds: 30,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// Create a consumer with listener
|
|
34
|
-
const consumer = await client.subscribe({
|
|
35
|
-
topic: 'persistent://public/default/my-topic',
|
|
36
|
-
subscription: 'sub1',
|
|
37
|
-
subscriptionType: 'Shared',
|
|
38
|
-
ackTimeoutMs: 10000,
|
|
39
|
-
listener: (msg, msgConsumer) => {
|
|
40
|
-
console.log(msg.getData().toString());
|
|
41
|
-
msgConsumer.acknowledge(msg);
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
})();
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const Pulsar = require('../');
|
|
21
|
-
|
|
22
|
-
(async () => {
|
|
23
|
-
const auth = new Pulsar.AuthenticationTls({
|
|
24
|
-
certificatePath: '/path/to/client.crt',
|
|
25
|
-
privateKeyPath: '/path/to/client.key',
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
// Create a client
|
|
29
|
-
const client = new Pulsar.Client({
|
|
30
|
-
serviceUrl: 'pulsar+ssl://localhost:6651',
|
|
31
|
-
authentication: auth,
|
|
32
|
-
tlsTrustCertsFilePath: '/path/to/server.crt',
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
// Create a consumer
|
|
36
|
-
const consumer = await client.subscribe({
|
|
37
|
-
topic: 'persistent://public/default/my-topic',
|
|
38
|
-
subscription: 'sub1',
|
|
39
|
-
subscriptionType: 'Shared',
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// Receive messages
|
|
43
|
-
for (let i = 0; i < 10; i += 1) {
|
|
44
|
-
const msg = await consumer.receive();
|
|
45
|
-
console.log(msg.getData().toString());
|
|
46
|
-
consumer.acknowledge(msg);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
await consumer.close();
|
|
50
|
-
await client.close();
|
|
51
|
-
})();
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const { exit } = require('process');
|
|
21
|
-
const Pulsar = require('../');
|
|
22
|
-
console.log("Starting consumer");
|
|
23
|
-
(async () => {
|
|
24
|
-
|
|
25
|
-
const auth = new Pulsar.AuthenticationToken({token: "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJKb2UifQ.ipevRNuRP6HflG8cFKnmUPtypruRC4fb1DWtoLL62SY"});
|
|
26
|
-
|
|
27
|
-
// Create a client
|
|
28
|
-
const client = new Pulsar.Client({
|
|
29
|
-
serviceUrl: 'pulsar://localhost:6650',
|
|
30
|
-
authentication: auth,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// Create a consumer
|
|
34
|
-
const consumer = await client.subscribe({
|
|
35
|
-
topic: 'persistent://public/default/my-topic',
|
|
36
|
-
subscription: 'sub1',
|
|
37
|
-
subscriptionType: 'Shared',
|
|
38
|
-
ackTimeoutMs: 10000,
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// Receive messages
|
|
42
|
-
for (let i = 0; i < 10; i += 1) {
|
|
43
|
-
const msg = await consumer.receive();
|
|
44
|
-
console.log(msg.getData().toString());
|
|
45
|
-
consumer.acknowledge(msg);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
await consumer.close();
|
|
49
|
-
await client.close();
|
|
50
|
-
})();
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const { exit } = require('process');
|
|
21
|
-
const Pulsar = require('..');
|
|
22
|
-
console.log("Starting consumer");
|
|
23
|
-
|
|
24
|
-
async function getToken() {
|
|
25
|
-
console.log("Get token");
|
|
26
|
-
return "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJKb2UifQ.ipevRNuRP6HflG8cFKnmUPtypruRC4fb1DWtoLL62SY";
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
(async () => {
|
|
30
|
-
|
|
31
|
-
const auth = new Pulsar.AuthenticationToken({token: getToken});
|
|
32
|
-
|
|
33
|
-
// Create a client
|
|
34
|
-
const client = new Pulsar.Client({
|
|
35
|
-
serviceUrl: 'pulsar://localhost:6650',
|
|
36
|
-
authentication: auth,
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
// Create a consumer
|
|
40
|
-
const consumer = await client.subscribe({
|
|
41
|
-
topic: 'persistent://public/default/my-topic',
|
|
42
|
-
subscription: 'sub1',
|
|
43
|
-
subscriptionType: 'Shared',
|
|
44
|
-
ackTimeoutMs: 10000,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
// Receive messages
|
|
48
|
-
for (let i = 0; i < 10; i += 1) {
|
|
49
|
-
const msg = await consumer.receive();
|
|
50
|
-
console.log(msg.getData().toString());
|
|
51
|
-
consumer.acknowledge(msg);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
await consumer.close();
|
|
55
|
-
await client.close();
|
|
56
|
-
})();
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const Pulsar = require('..');
|
|
21
|
-
|
|
22
|
-
(async () => {
|
|
23
|
-
// Create a client
|
|
24
|
-
const client = new Pulsar.Client({
|
|
25
|
-
serviceUrl: 'pulsar://localhost:6650',
|
|
26
|
-
operationTimeoutSeconds: 30,
|
|
27
|
-
log: (level, file, line, message) => {
|
|
28
|
-
console.log('[%s][%s:%d] %s', Pulsar.LogLevel.toString(level), file, line, message);
|
|
29
|
-
},
|
|
30
|
-
logLevel: Pulsar.LogLevel.DEBUG,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// Create a producer
|
|
34
|
-
const producer = await client.createProducer({
|
|
35
|
-
topic: 'persistent://public/default/my-topic',
|
|
36
|
-
sendTimeoutMs: 30000,
|
|
37
|
-
batchingEnabled: true,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// Create a consumer
|
|
41
|
-
const consumer = await client.subscribe({
|
|
42
|
-
topic: 'persistent://public/default/my-topic',
|
|
43
|
-
subscription: 'sub1',
|
|
44
|
-
subscriptionType: 'Shared',
|
|
45
|
-
ackTimeoutMs: 10000,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const msg = `my-message`;
|
|
49
|
-
await producer.send({
|
|
50
|
-
data: Buffer.from(msg),
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const receivedMsg = await consumer.receive();
|
|
54
|
-
console.log(receivedMsg.getData().toString());
|
|
55
|
-
await consumer.acknowledge(receivedMsg);
|
|
56
|
-
|
|
57
|
-
await producer.close();
|
|
58
|
-
await consumer.close();
|
|
59
|
-
await client.close();
|
|
60
|
-
})();
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const Pulsar = require('../');
|
|
21
|
-
|
|
22
|
-
(async () => {
|
|
23
|
-
// Create a client
|
|
24
|
-
const client = new Pulsar.Client({
|
|
25
|
-
serviceUrl: 'pulsar://localhost:6650',
|
|
26
|
-
operationTimeoutSeconds: 30
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
// Create a consumer
|
|
30
|
-
const consumer = await client.subscribe({
|
|
31
|
-
topic: 'persistent://public/default/my-topic',
|
|
32
|
-
subscription: 'sub1',
|
|
33
|
-
subscriptionType: 'Shared',
|
|
34
|
-
ackTimeoutMs: 10000,
|
|
35
|
-
privateKeyPath: "./certificate/private-key.client-rsa.pem"
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// Receive messages
|
|
39
|
-
for (let i = 0; i < 10; i += 1) {
|
|
40
|
-
const msg = await consumer.receive();
|
|
41
|
-
console.log(msg.getData().toString());
|
|
42
|
-
consumer.acknowledge(msg);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
await consumer.close();
|
|
46
|
-
await client.close();
|
|
47
|
-
})();
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const Pulsar = require('../');
|
|
21
|
-
|
|
22
|
-
(async () => {
|
|
23
|
-
// Create a client
|
|
24
|
-
const client = new Pulsar.Client({
|
|
25
|
-
serviceUrl: 'pulsar://localhost:6650',
|
|
26
|
-
operationTimeoutSeconds: 30,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
// Create a producer
|
|
30
|
-
const producer = await client.createProducer({
|
|
31
|
-
topic: 'persistent://public/default/my-topic',
|
|
32
|
-
sendTimeoutMs: 30000,
|
|
33
|
-
batchingEnabled: true,
|
|
34
|
-
publicKeyPath: "./certificate/public-key.client-rsa.pem",
|
|
35
|
-
encryptionKey: "encryption-key"
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// Send messages
|
|
39
|
-
for (let i = 0; i < 10; i += 1) {
|
|
40
|
-
const msg = `my-message-${i}`;
|
|
41
|
-
producer.send({
|
|
42
|
-
data: Buffer.from(msg),
|
|
43
|
-
});
|
|
44
|
-
console.log(`Sent message: ${msg}`);
|
|
45
|
-
}
|
|
46
|
-
await producer.flush();
|
|
47
|
-
|
|
48
|
-
await producer.close();
|
|
49
|
-
await client.close();
|
|
50
|
-
})();
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const Pulsar = require('../');
|
|
21
|
-
|
|
22
|
-
(async () => {
|
|
23
|
-
// Create a client
|
|
24
|
-
const client = new Pulsar.Client({
|
|
25
|
-
serviceUrl: 'pulsar://localhost:6650',
|
|
26
|
-
operationTimeoutSeconds: 30
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
// Create a reader
|
|
30
|
-
const reader = await client.createReader({
|
|
31
|
-
topic: 'persistent://public/default/my-topic',
|
|
32
|
-
startMessageId: Pulsar.MessageId.earliest(),
|
|
33
|
-
privateKeyPath: './certificate/private-key.client-rsa.pem'
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
// Receive messages
|
|
37
|
-
for (let i = 0; i < 10; i += 1) {
|
|
38
|
-
const msg = await reader.readNext();
|
|
39
|
-
console.log(msg.getData().toString());
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
await reader.close();
|
|
43
|
-
await client.close();
|
|
44
|
-
})();
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const Pulsar = require('../');
|
|
21
|
-
|
|
22
|
-
(async () => {
|
|
23
|
-
|
|
24
|
-
// Create a client
|
|
25
|
-
const client = new Pulsar.Client({
|
|
26
|
-
serviceUrl: 'pulsar://localhost:6650',
|
|
27
|
-
operationTimeoutSeconds: 30,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const schemaInfo = {
|
|
31
|
-
schemaType: "Json",
|
|
32
|
-
schema: JSON.stringify({
|
|
33
|
-
type: 'record',
|
|
34
|
-
name: 'Example',
|
|
35
|
-
namespace: 'test',
|
|
36
|
-
fields: [
|
|
37
|
-
{
|
|
38
|
-
name: 'a',
|
|
39
|
-
type: 'int',
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: 'b',
|
|
43
|
-
type: 'int',
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
}),
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const message = {
|
|
50
|
-
a: 1,
|
|
51
|
-
b: 2,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
// Create a producer
|
|
55
|
-
const producer = await client.createProducer({
|
|
56
|
-
topic: 'persistent://public/default/schema-test',
|
|
57
|
-
sendTimeoutMs: 30000,
|
|
58
|
-
batchingEnabled: true,
|
|
59
|
-
schema: schemaInfo,
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// Send messages
|
|
63
|
-
for (let i = 0; i < 100; i += 1) {
|
|
64
|
-
message.a = i;
|
|
65
|
-
message.b = i * 2;
|
|
66
|
-
const data = JSON.stringify(message);
|
|
67
|
-
producer.send({
|
|
68
|
-
data: Buffer.from(data),
|
|
69
|
-
});
|
|
70
|
-
console.log(`Sent message: ${data}`);
|
|
71
|
-
}
|
|
72
|
-
await producer.flush();
|
|
73
|
-
|
|
74
|
-
await producer.close();
|
|
75
|
-
await client.close();;
|
|
76
|
-
})();
|
package/examples/producer.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const Pulsar = require('../');
|
|
21
|
-
|
|
22
|
-
(async () => {
|
|
23
|
-
// Create a client
|
|
24
|
-
const client = new Pulsar.Client({
|
|
25
|
-
serviceUrl: 'pulsar://localhost:6650',
|
|
26
|
-
operationTimeoutSeconds: 30,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
// Create a producer
|
|
30
|
-
const producer = await client.createProducer({
|
|
31
|
-
topic: 'persistent://public/default/my-topic',
|
|
32
|
-
sendTimeoutMs: 30000,
|
|
33
|
-
batchingEnabled: true,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
// Send messages
|
|
37
|
-
for (let i = 0; i < 10; i += 1) {
|
|
38
|
-
const msg = `my-message-${i}`;
|
|
39
|
-
producer.send({
|
|
40
|
-
data: Buffer.from(msg),
|
|
41
|
-
});
|
|
42
|
-
console.log(`Sent message: ${msg}`);
|
|
43
|
-
}
|
|
44
|
-
await producer.flush();
|
|
45
|
-
|
|
46
|
-
await producer.close();
|
|
47
|
-
await client.close();
|
|
48
|
-
})();
|