Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
next => {
testProducer = new Producer({
'metadata.broker.list': config.kafka.hosts,
});
testProducer.connect();
testProducer.on('ready', () => next());
testProducer.on('event.error', error => {
assert.ifError(error);
});
},
// create topics by fetching metadata from these topics
next => {
testProducer = new Producer({
'metadata.broker.list': config.kafka.hosts,
});
testProducer.connect();
testProducer.on('ready', () => next());
testProducer.on('event.error', error => {
assert.ifError(error);
});
},
// create topics by fetching metadata from these topics
const Kafka = require('node-rdkafka');
const config = require('./setting');
console.log("features:" + Kafka.features);
console.log(Kafka.librdkafkaVersion);
var producer = new Kafka.Producer({
/*'debug': 'all', */
'api.version.request': 'true',
'bootstrap.servers': config['bootstrap_servers'],
'dr_cb': true,
'dr_msg_cb': true,
'security.protocol' : 'sasl_ssl',
'ssl.ca.location' : './ca-cert',
'sasl.mechanisms' : 'PLAIN',
'sasl.username' : config['sasl_plain_username'],
'sasl.password' : config['sasl_plain_password']
});
var connected = false
// Poll for events every 100 ms
producer.setPollInterval(100);
/* Copyright (c) Microsoft Corporation. All rights reserved.
* Copyright (c) 2016 Blizzard Entertainment
* Licensed under the MIT License.
*
* Original Blizzard node-rdkafka sample modified for use with Azure Event Hubs for Apache Kafka Ecosystems
*/
var Kafka = require('node-rdkafka');
var producer = new Kafka.Producer({
//'debug' : 'all',
'metadata.broker.list': 'mynamespace.servicebus.windows.net:9093', //REPLACE
'dr_cb': true, //delivery report callback
'security.protocol': 'SASL_SSL',
'sasl.mechanisms': 'PLAIN',
'sasl.username': '$ConnectionString', //do not replace $ConnectionString
'sasl.password': 'Endpoint=sb://mynamespace.servicebus.windows.net/;SharedAccessKeyName=XXXXXX;SharedAccessKey=XXXXXX' //REPLACE
});
var topicName = 'test';
//logging debug messages, if debug is enabled
producer.on('event.log', function(log) {
console.log(log);
});
return new Promise(function(resolve, reject) {
let msgsCount = 1;
if(Array.isArray(msgs)){
msgsCount = msgs.length;
};
var producer = new Kafka.Producer({
/*'debug': 'all', */
'api.version.request': 'true',
'bootstrap.servers': config['bootstrap_servers'],
'dr_cb': true,
'dr_msg_cb': true,
'security.protocol' : 'sasl_ssl',
'ssl.ca.location' : './ca-cert',
'sasl.mechanisms' : 'PLAIN',
'sasl.username' : config['sasl_plain_username'],
'sasl.password' : config['sasl_plain_password']
});
// Poll for events every 100 ms
producer.setPollInterval(100);
// Connect to the broker manually
Producer.prototype.getProducer = Promise.method(function (opts, topicOptions) {
if (!opts) {
opts = {};
}
if (!opts['metadata.broker.list']) {
opts['metadata.broker.list'] = this.kafkaBrokerUrl;
}
log.info('getProducer() :: Starting producer with options:', opts);
const producer = new kafka.Producer(opts, topicOptions);
this._producers.push(producer);
// hack node-rdkafka
producer.__kafkaAvro_produce = producer.produce;
producer.produce = this._produceWrapper.bind(this, producer);
return new Promise(function (resolve, reject) {
producer.on('ready', function () {
log.debug('getProducer() :: Got "ready" event.');
resolve(producer);
});
producer.connect({}, function (err) {
if (err) {
log.error({err}, 'getProducer() :: Connect failed:');
function createProducer(onDeliveryReport) {
const producer = new Kafka.Producer({
'bootstrap.servers': process.env.KAFKA_URI,
'security.protocol': 'SASL_SSL',
'sasl.mechanisms': 'PLAIN',
'sasl.username': process.env.KAFKA_KEY,
'sasl.password': process.env.kAFKA_SECRET,
'dr_msg_cb': true
});
producer.setPollInterval(100);
return new Promise((resolve, reject) => {
producer
.on('ready', () => {
console.log("producer ready");
resolve(producer);
var Kafka = require('node-rdkafka');
var producer = new Kafka.Producer({
//'debug' : 'all',
'metadata.broker.list': 'EVENTHUB_FQDN',
'dr_cb': true, //delivery report callback
'security.protocol': 'SASL_SSL',
'sasl.mechanisms': 'PLAIN',
'sasl.username': '$ConnectionString',
'sasl.password': 'EVENTHUB_CONNECTION_STRING'
});
var topicName = 'test';
//logging debug messages, if debug is enabled
producer.on('event.log', function(log) {
console.log(log);
});
const mqtt = require('mqtt');
const Kafka = require('node-rdkafka');
/////////////////#
const topic = '/hfp/v2/journey/ongoing/vp/+/+/+/+/+/+/+/+/+/#';
const client = mqtt.connect('mqtts://mqtt.hsl.fi:8883');
const producer = new Kafka.Producer({
'client.id': 'vp-producer',
'metadata.broker.list': 'kafka:9092',
'dr_cb': true
});
client.on('connect', function () {
client.subscribe(topic);
console.log('Connected');
});
producer.setPollInterval(100);
producer.connect();
producer.on('ready', () => {
client.on('message', (topic, message) => {
try {