Constructor
new Kafka(connectionObject, configs)
- Description:
- Source:
Parameters:
Name |
Type |
Description |
connectionObject |
Object
|
|
configs |
Map
|
|
Extends
Methods
(async, static) getConsumer(client, topic, consumerGroup) → {Promise.<Object>}
- Description:
- Source:
Example
const mdx = require("@nvidia-mdx/web-api-core");
const kafka = new mdx.Utils.Kafka({brokers: ["kafka-broker-url"]}, kafkaConfigMap);
let consumer = await kafka.getConsumer(kafka.getClient(), topic, consumerGroup);
Parameters:
Name |
Type |
Description |
client |
Object
|
|
topic |
string
|
|
consumerGroup |
string
|
|
Returns:
Kafka consumer is returned
-
Type
-
Promise.<Object>
(static) getTopic(topicType) → {string|undefined}
- Description:
- Source:
Example
const mdx = require("@nvidia-mdx/web-api-core");
let topicType = "notification";
let topic = mdx.Utils.Kafka.getTopic(topicType);
Parameters:
Name |
Type |
Description |
topicType |
string
|
|
Returns:
Returns topic
-
Type
-
string
|
undefined
(async, static) produceMessages(client, topic, messages) → {Promise.<Object>}
- Description:
- returns a success message once the input messages are produced
- Source:
Example
const mdx = require("@nvidia-mdx/web-api-core");
const kafka = new mdx.Utils.Kafka({brokers: ["kafka-broker-url"]}, kafkaConfigMap);
let result = await kafka.produceMessages(kafka.getClient(), topic, messages);
Parameters:
Name |
Type |
Description |
client |
Object
|
|
topic |
string
|
|
messages |
Array.<Object>
|
Each message will have value and may contain key and headers. |
Returns:
A success message is returned
-
Type
-
Promise.<Object>