我正在使用kafka-node从我的node.js网络服务器生成消息。我的消费者是另一个后端系统(用c librdkafka编写)。
我想知道如何发送键控消息(使用kafka-node),其中键是int(枚举)而不是字符串..
node.js代码(生产者):
var kafka = require('kafka-node'),
Producer = kafka.Producer,
KeyedMessage = kafka.KeyedMessage,
client = new kafka.Client(),
producer = new Producer(client),
km = new KeyedMessage(1, (new MessageTypeSystemStatus({trace: [{ }] })).encode()),
payloads = [
{ topic: 'Genesis', messages: km, partition: 0 }
];
C ++代码(消费者):
Message* msg = mConsumer->consume(mTopic, mPartition, -1);
*(msg->key_pointer());