npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Headers values sent as a Byte Array

What I Wanted to Do

I wanted to send a Kafka Message with a Header to a Spring Boot Application that had a StreamListener that was configured to watch for messages with this header.

What Happened Instead

Spring Boot Application did not pick up message.

The Spring Boot Application could not filter for the message header as Kafkajs seems to send the Headers values as a Byte Array (although the Message Header Key is transmitted a String).

Rewrote using Java Spring Message Writer and the Header value came through as expected.

Reproduction Steps

Just send a message with a Header in Kafkajs, e.g
async function sendMessage() {
await producer.connect();
await producer.send({
topic: ‘device’,
messages: [
headers: { ‘message-type’: ‘DEVICE_INITIALISED’ },
value: ‘’
await producer.disconnect()


Platform Info

$ npm --versions
{ 'message-headers-spike': '1.0.0',
  npm: '6.4.1',
  ares: '1.10.1-DEV',
  cldr: '31.0.1',
  http_parser: '2.7.0',
  icu: '59.1',
  modules: '57',
  nghttp2: '1.25.0',
  node: '8.9.1',
  openssl: '1.0.2m',
  tz: '2017b',
  unicode: '9.0',
  uv: '1.15.0',
  v8: '6.1.534.47',
  zlib: '1.2.11' }
$ node -p process.platform

(You might get an answer here, but because this forum is focused on npm, you might want to ask your question somewhere that targets experts with your package. I have moved your topic to #community:javascript)