@itentialopensource/adapter-kafkav2 0.12.0 → 0.13.0
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/CHANGELOG.md +8 -0
- package/README.md +63 -110
- package/package.json +1 -1
- package/refs?service=git-upload-pack +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
|
|
2
|
+
## 0.13.0 [08-03-2023]
|
|
3
|
+
|
|
4
|
+
* Add seperate sasl props for consumer and producer
|
|
5
|
+
|
|
6
|
+
See merge request itentialopensource/adapters/notification-messaging/adapter-kafkav2!10
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
2
10
|
## 0.12.0 [08-03-2023]
|
|
3
11
|
|
|
4
12
|
* Add seperate sasl props for consumer and producer
|
package/README.md
CHANGED
|
@@ -75,6 +75,39 @@ git clone git@gitlab.com:\@itentialopensource/adapters/adapter-Kafkav2
|
|
|
75
75
|
npm install
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
+
## Installing an Itential Product Adapter
|
|
79
|
+
|
|
80
|
+
1. Set up the name space location in your IAP node_modules.
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
cd /opt/pronghorn/current/node_modules
|
|
84
|
+
if the @itentialopensource directory does not exist, create it:
|
|
85
|
+
mkdir @itentialopensource
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
1. Clone the adapter into your IAP environment.
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
cd \@itentialopensource
|
|
92
|
+
git clone git@gitlab.com:\@itentialopensource/adapters/adapter-Kafka
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
1. Install the dependencies for the adapter.
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
cd adapter-Kafka
|
|
99
|
+
npm install
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
1. Add the adapter properties for Kafka (created from Adapter Builder) to the `properties.json` file for your Itential build. You will need to change the credentials and possibly the host information below.
|
|
103
|
+
[Kafka sample properties](sampleProperties.json)
|
|
104
|
+
|
|
105
|
+
1. Restart IAP
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
systemctl restart pronghorn
|
|
109
|
+
```
|
|
110
|
+
|
|
78
111
|
## Adapter Properties and Descriptions
|
|
79
112
|
|
|
80
113
|
This section defines **all** the properties that are available for the adapter, including detailed information on what each property is for. If you are not using certain capabilities with this adapter, you do not need to define all of the properties. An example of how the properties for this adapter can be used with tests or IAP are provided in the **Installation** section.
|
|
@@ -96,9 +129,7 @@ This section defines **all** the properties that are available for the adapter,
|
|
|
96
129
|
"brokers": [
|
|
97
130
|
"broker:9093"
|
|
98
131
|
],
|
|
99
|
-
"clientId": "my-app"
|
|
100
|
-
"ssl": {},
|
|
101
|
-
"sasl": {}
|
|
132
|
+
"clientId": "my-app"
|
|
102
133
|
},
|
|
103
134
|
"producer": {
|
|
104
135
|
"requireAcks": 1,
|
|
@@ -247,10 +278,10 @@ These base properties are used to connect to Kafka upon the adapter initially co
|
|
|
247
278
|
|
|
248
279
|
| Property | Description |
|
|
249
280
|
| ------- | ------- |
|
|
250
|
-
| host | Optional. A fully qualified domain name or IP address.|
|
|
251
|
-
| port | Required if `host` set. Used to connect to the server
|
|
281
|
+
| host | Optional. A fully qualified domain name or IP address. This is not needed for latest version of the adapter as the broker is set under client properties.|
|
|
282
|
+
| port | Required if `host` set. Used to connect to the server. This is not needed for latest version of the adapter as the port is set under client properties|
|
|
252
283
|
| interval_time | Optional. The Kafka adapter keeps information about topics and offsets in memory in order to be more efficient. In order to work across restarts the adapter must persist the data. So the data is written into the .topics.json file. This write time defines how often to write the file.|
|
|
253
|
-
| stub | Optional.
|
|
284
|
+
| stub | Optional. Slightly different meaning than normal, this is just telling the adapter to not actually send any request to kafka and mock a healthy connection. Should be set to false unless you are wanting to force the adapter to be green without an actual connection.|
|
|
254
285
|
|
|
255
286
|
#### Important
|
|
256
287
|
When adapter works in consumer configuration: `autoCommit:false` `fromOffset:true` current offset setting on adapter startup is loaded from .topic.json file for each (topic:partition).
|
|
@@ -301,6 +332,8 @@ The `parseMessage` property allows the user to define how they want the Kafka me
|
|
|
301
332
|
|
|
302
333
|
## Send message sample payload
|
|
303
334
|
|
|
335
|
+
Note that this is an array, so it can have multiple topics.
|
|
336
|
+
|
|
304
337
|
```json
|
|
305
338
|
[{
|
|
306
339
|
"topic": "topic-name",
|
|
@@ -312,122 +345,42 @@ The `parseMessage` property allows the user to define how they want the Kafka me
|
|
|
312
345
|
```
|
|
313
346
|
For all options of messages array please follow [kafkajs documentation](https://kafka.js.org/docs/producing#producing-messages)
|
|
314
347
|
|
|
315
|
-
##
|
|
316
|
-
|
|
317
|
-
Mocha is generally used to test all Itential Product Adapters. There are unit tests as well as integration tests performed. Integration tests can generally be run as standalone using mock data and running the adapter in stub mode, or as integrated. When running integrated, every effort is made to prevent environmental failures, however there is still a possibility.
|
|
348
|
+
## Triggering jobs in IAP from a kafka message
|
|
318
349
|
|
|
319
|
-
|
|
350
|
+
Once you have the adapter configured and online in an IAP instance, you can create triggers in Operations Manager to kick off jobs when a kafka message is consumed. The adapter listens for messages on the subscribed topics and publishes to an event. This event is picked up by the Operations Manager. If you have created triggers for this specific topic, a job will get triggered. For a step-by-step example follow the next sub-section.
|
|
320
351
|
|
|
321
|
-
|
|
352
|
+
### Listen to a topic called test-topic and trigger a workflow called test
|
|
322
353
|
|
|
354
|
+
1. Subscribe to partition 0 of test-topic. Add this to your adapter service config. To see different options of topic properties see PROPERTIES.md
|
|
323
355
|
|
|
324
356
|
```json
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
answer no at the first prompt
|
|
341
|
-
|
|
342
|
-
npm run test:integration
|
|
343
|
-
```
|
|
344
|
-
|
|
345
|
-
To add new integration tests, edit the `test/integration/adapterTestIntegration.js` file. The tests that are already in this file should provide guidance for adding additional tests.
|
|
346
|
-
|
|
347
|
-
### Integration Testing
|
|
348
|
-
|
|
349
|
-
Integration Testing requires connectivity to Kafka. By using the testRunner script it prevents you from having to edit the integration test. It also resets the integration test after the test is complete so that credentials are not saved in the file.
|
|
350
|
-
|
|
351
|
-
> **Note**: These tests have been written as a best effort to make them work in most environments. However, the Adapter Builder often does not have the necessary information that is required to set up valid integration tests. For example, the order of the requests can be very important and data is often required for `creates` and `updates`. Hence, integration tests may have to be enhanced before they will work (integrate) with Kafka. Even after tests have been set up properly, it is possible there are environmental constraints that could result in test failures. Some examples of possible environmental issues are customizations that have been made within Kafka which change order dependencies or required data.
|
|
352
|
-
|
|
353
|
-
```json
|
|
354
|
-
node utils/testRunner
|
|
355
|
-
answer yes at the first prompt
|
|
356
|
-
answer all other questions on connectivity and credentials
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
Test should also be written to clean up after themselves. However, it is important to understand that in some cases this may not be possible. In addition, whenever exceptions occur, test execution may be stopped, which will prevent cleanup actions from running. It is recommended that tests be utilized in dev and test labs only.
|
|
360
|
-
|
|
361
|
-
> **Reminder**: Do not check in code with actual credentials to systems.
|
|
362
|
-
|
|
363
|
-
## Installing an Itential Product Adapter
|
|
364
|
-
|
|
365
|
-
1. Set up the name space location in your IAP node_modules.
|
|
366
|
-
|
|
367
|
-
```json
|
|
368
|
-
cd /opt/pronghorn/current/node_modules
|
|
369
|
-
if the @itentialopensource directory does not exist, create it:
|
|
370
|
-
mkdir @itentialopensource
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
1. Clone the adapter into your IAP environment.
|
|
374
|
-
|
|
375
|
-
```json
|
|
376
|
-
cd \@itentialopensource
|
|
377
|
-
git clone git@gitlab.com:\@itentialopensource/adapters/adapter-Kafka
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
1. Install the dependencies for the adapter.
|
|
381
|
-
|
|
382
|
-
```json
|
|
383
|
-
cd adapter-Kafka
|
|
384
|
-
npm install
|
|
385
|
-
```
|
|
386
|
-
|
|
387
|
-
1. Add the adapter properties for Kafka (created from Adapter Builder) to the `properties.json` file for your Itential build. You will need to change the credentials and possibly the host information below.
|
|
388
|
-
[Kafka sample properties](sampleProperties.json)
|
|
389
|
-
|
|
390
|
-
1. Restart IAP
|
|
391
|
-
|
|
392
|
-
```json
|
|
393
|
-
systemctl restart pronghorn
|
|
394
|
-
```
|
|
395
|
-
|
|
396
|
-
## Installing a Custom Adapter
|
|
397
|
-
|
|
398
|
-
If you built this as a custom adapter through the Adapter Builder, it is recommended you go through setting up a development environment and testing the adapter before installing it. There is often configuration and authentication work that is required before the adapter will work in IAP.
|
|
399
|
-
|
|
400
|
-
1. Move the adapter into the IAP `node_modules` directory.
|
|
401
|
-
|
|
402
|
-
```json
|
|
403
|
-
Depending on where your code is located, this process is different.
|
|
404
|
-
Could be a tar, move, untar
|
|
405
|
-
Could be a git clone of a repository
|
|
406
|
-
Could also be a cp -R from a coding directory
|
|
407
|
-
Adapter should be placed into: /opt/pronghorn/current/node_modules/\@itentialopensource
|
|
357
|
+
"topics": [
|
|
358
|
+
{
|
|
359
|
+
"name": "test-topic",
|
|
360
|
+
"always": true,
|
|
361
|
+
"partition": 0,
|
|
362
|
+
"subscriberInfo": [
|
|
363
|
+
{
|
|
364
|
+
"subname": "default",
|
|
365
|
+
"filters": [],
|
|
366
|
+
"rabbit": "test-topic-rabbit",
|
|
367
|
+
"throttle": {}
|
|
368
|
+
}
|
|
369
|
+
]
|
|
370
|
+
}
|
|
371
|
+
],
|
|
408
372
|
```
|
|
409
373
|
|
|
410
|
-
|
|
374
|
+
Note the rabbit key in the config is set to kafka. The adapter will send any message on test-topic-rabbit to a Rabbit queue named kafka. If no rabbit topic is supplied, events will be published to a topic with the same name as the Kafka topic. Also note that the filter array can be left empty to consume all messages on partion 0 of test-topic.
|
|
411
375
|
|
|
412
|
-
|
|
376
|
+
2. Create an automation in Operations Manager
|
|
413
377
|
|
|
414
|
-
|
|
378
|
+
Create a new automation, and add a trigger.
|
|
415
379
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
```json
|
|
419
|
-
connect()
|
|
420
|
-
The connect call is run when the Adapter is first loaded by he Itential Platform. It validates the properties have been provided correctly.
|
|
421
|
-
```
|
|
422
|
-
|
|
423
|
-
```json
|
|
424
|
-
healthCheck(callback)
|
|
425
|
-
Insures that the adapter can communicate with Kafka. The actual call that is used is defined in the adapter properties.
|
|
426
|
-
```
|
|
380
|
+
When selecting the Event for your trigger, make sure to select test-topic-rabbit from the drop down list. This is critical as the adpater will be sending the message on this queue. You can add filtering in the trigger by providing a Payload Schema Filter.
|
|
427
381
|
|
|
428
|
-
|
|
382
|
+
After saving the trigger, select the workflow you want to trigger. Save the Automation and view all jobs to see a job getting triggered as soon as a message is published on test-topic partition 0.
|
|
429
383
|
|
|
430
|
-
Specific adapter calls are built based on the API of the Kafka. The Adapter Builder creates the proper method comments for generating JS-DOC for the adapter. This is the best way to get information on the calls.
|
|
431
384
|
|
|
432
385
|
## Troubleshooting the Adapter
|
|
433
386
|
|
package/package.json
CHANGED
|
Binary file
|