CDS pluginCDS plugintypeInstalls into a CAP project and extends the runtime. CAP loads it through cds.requires or the plugin hook.See every one →What this type is →independently maintainedindependently maintainedoriginPublished by one person or a small company outside SAP. Says nothing about quality; the readings say that.See every one →

cds-kafka

A Kafka adapter for CAP that registers Kafka topics as a CDS messaging service over KafkaJS, so emit and on work unchanged, with per-message keys, partitions and topics set through headers.

CAP's messaging kinds reach SAP's own brokers, and the Apache Kafka adapter sitting in the CAP sources is bound to an internal SAP BTP service that is not publicly available, so a CAP application that has to speak to a Kafka cluster of its own has no configured path to it. cds-kafka registers a messaging service whose impl is the plugin and passes its credentials block straight into KafkaJS, leaving emit and on as CAP defines them: the producer and consumer samples in SAP-samples/cloud-cap-samples were moved onto Kafka without touching application code. On top of that it carries what Kafka needs and a CDS event does not describe — a key, a partition and a topic name set per message through @kafka. headers, subscriptions by regular expression or *, and automatic topic creation — and hands the partition, offset and timestamp a message arrived with back to the handler as headers. It stops at the broker's own contracts: there is no schema registry support, and a regex subscription only matches topics that already existed when the application started.

Facts

Latestv0.1.4ReleasedLast pushLicenceMIT

Where it sits

Lives in
Provides
Event MeshCAPEvent MeshcapabilityEmitting and consuming business events across systems through brokers, including subscriptions and mapping application events to broker topics. Work that must survive a request, including deferred processing and retries, belongs to [async processing](capability:async-processing).
Flavors
Node.jsfrom its runtime
Runs
Cloud Foundrylocal
Requires
@sap/cds≥ 7@sap/cdsartifactThe peer range, as published.Apache KafkaApache Kafkaoutside the atlasThe broker the messaging service talks to. cds-kafka reaches it through KafkaJS, and the credentials block is handed to the KafkaJS constructor, so a cluster in Docker on a laptop and a managed one in a cloud are configured the same way.

Who is behind it

Mike ZaschkaMike ZaschkaPersonMaintains this
In the atlas: maintains 6, contributes to 9, wrote 12
@mikezaschka
maintainer

Before choosing this

Conditions

LicenceSAP Developer License Agreement 3.1§ 1The package is used within an SAP Cloud Application based on @sap/cds, especially to move SAP data through Kafka.
  • § 1 License. The agreement grants limited rights for customer applications and states that those applications must not permit mass extraction from an SAP product to a non-SAP product.

The package is MIT-licensed, but its README separately states that use within SAP Cloud Applications is subject to the SAP Developer License. Review section 1 for a use that moves data from an SAP product to a non-SAP product.

SAP Developer License Agreement 3.1 →

What it declares

Every artifact

Type
CDS plugin
Origin
Independently maintained
Runtime
Node.js
Runs on
Cloud Foundrylocal

As a CDS plugin

Declared for
>=7
Distributed through
npm

Tasks this contributes to1Beta

Receive messages from an Apache Kafka topicRecords that another system writes to a topic on an Apache Kafka cluster reach a handler in the application, which processes each one as an event.Node.js, JavaCoversbroker client
What it does

Registers a CAP messaging service whose implementation connects to the Kafka brokers through KafkaJS, so messaging.on('some-topic', handler) subscribes to the Kafka topic of that name. A subscription can also be a regular expression or a catch-all, and every consumed message carries headers with the Kafka topic, partition, offset and timestamp. consumer.groupId sets the consumer group, and fromBeginning per topic decides whether records already in the topic are read.

Remaining work

Install the plugin, configure the messaging service with the brokers and credentials, set a consumer group and write the handler. A regular-expression subscription matches only topics that exist when the application starts. The README's list of open work names the Confluent schema registry, so decoding records written through a schema registry is the application's own code.

All options on the Event Mesh page →

Connections4

cds-kafka connectionscds-kafkaFUNCTIONAL→ alternative to1alternative to authored@cap-js-community/event-queue→ provides1provides stated Implements a CAP messaging service over Apache Kafka, mapping a CDS event onto a Kafka topic in both directions, with the topic name, key and partition settable per message and subscriptions declarable as a regular expression or a catch-all. cds-kafka — README: https://github.com/mikezaschka/cds-kafka Using Apache Kafka for messaging in the SAP Cloud Application Programming Model (CAP) – Part 1/2 — SAP Community: https://community.sap.com/t5/technology-blog-posts-by-members/using-apache-kafka-for-messaging-in-the-sap-cloud-application-programming/ba-p/13970176Event MeshNEEDS→ connects to1connects to stated Publishing CAP events to Kafka topics and subscribing to topics to receive messages, through the CAP messaging API. cds-kafka — README, Features: https://raw.githubusercontent.com/mikezaschka/cds-kafka/6d821c76764e7465e2280ae556c0c8814cd563cd/readme.md cds-kafka — README, Features: https://raw.githubusercontent.com/mikezaschka/cds-kafka/6d821c76764e7465e2280ae556c0c8814cd563cd/readme.md cds-kafka — README, Setup: https://raw.githubusercontent.com/mikezaschka/cds-kafka/6d821c76764e7465e2280ae556c0c8814cd563cd/readme.mdApache Kafka→ needs1needs stated The broker the messaging service talks to. cds-kafka reaches it through KafkaJS, and the `credentials` block is handed to the KafkaJS constructor, so a cluster in Docker on a laptop and a managed one in a cloud are configured the same way. cds-kafka — README: https://github.com/mikezaschka/cds-kafkaApache Kafka

Install

npm add cds-kafka

Derived from the package name. No recipe recorded; the README has the configuration.

Learn more2

Readings
  1. Using Apache Kafka for messaging in the SAP Cloud Application Programming Model (CAP) – Part 2/2Mike Zaschka, SAP Community
  2. Using Apache Kafka for messaging in the SAP Cloud Application Programming Model (CAP) – Part 1/2Mike Zaschka, SAP Community

Where it sits in your app

Download
Your CAP applicationcds-kafka — README, Features, checked 2026-09-19: “Enables sending messages/events to Apache Kafka.”Kafka, TCP, bothApache Kafka, systemApache Kafkasystemcds-kafka, modulecds-kafka
SAPnot SAP's, or the project's ownstated in the document

README

quoted from mikezaschka/cds-kafka under MIT, read
mikezaschka/cds-kafka/readme.mdOn GitHub

Welcome to cds-kafka

About this project

This project is a plugin for the SAP Cloud Application Programming Model (CAP) providing native integration with Apache Kafka as the messaging service.

Features

cds-kafka offers the following capabilities:

  • CAP Integration: Seamlessly integrates with CAP’s native messaging framework for event handling.
  • Event Publishing: Enables sending messages/events to Apache Kafka.
  • Topic Subscription: Allows subscribing to one or multiple topics in Apache Kafka to receive incoming messages.
  • Advanced Topic Matching: Supports subscription to multiple topics using regular expressions.
  • CloudEvents Support: Provides built-in support for the CloudEvents specification.
  • Kafka-Specific Features: Leverages Kafka-specific capabilities, including the use of keys, partitions and topic subscription behavior.
  • Flexible Connectivity: Connects to Kafka instances hosted locally or in any cloud environment.
  • Topic Management: Automates the creation of topics in Kafka.

More information in the introductiory blog posts in the SAP Community:

Table of Contents

Requirements

See Getting Started on how to jumpstart your development and grow as you go with SAP Cloud Application Programming Model.

Licensing

cds-kafka is distributed under the MIT license. However, using cds-kafka within SAP Cloud Applications (@sap/cds) is subject to the SAP Developer License. Ensure that your use cases comply with all licensing terms and obligations.

Setup

Install the plugin in an existing CAP project via:

npm add cds-kafka

Add the configuration of the message service:

"cds": {
    "requires": {
        "messaging": {
            "kind": "kafka-service",
            "credentials": {
                "clientId": "my-cap-app",
                "brokers": [
                    "localhost:9028"
                ]
            },
            "consumer": {
                "groupId": "my-consumer-group"
            }
        },
        "kafka-service": {
            "impl": "cds-kafka"
        }
    }
}

Under the hood cds-kafka uses KafkaJS to connect to Kafka. Since Kafka itself uses a binary protocol over TCP, KafkaJS is the required abstraction layer to access Kafka functionality in JavaScript. The credentials are directy passed into the KafkaJS constructor making it possible to connect to any local or cloud-based Kafka instance. More information on the configuration options are available in the official KafkaJS documentation. Other configuration options for cds-kafka:

  • consumer.groupId: The Kafka groupId used when subscribing to a topic.
  • topicname.fromBeginning: Boolean if the subscription should receive messages from the beginning of the topic or only new ones.

If you need an example on how to setup and use cds-kafka locally or on SAP BTP, please check part 2 of the small blog series.

Usage

Please follow the guide on messaging to get an overview over the messaging concepts of CAP. cds-kafka supports the native CAP APIs for sending and subscribing to events/messages.

Send a message to a Kafka topic some-topic:

const messaging = await cds.connect.to('messaging') 
await messaging.emit('some-topic', { subject: 'Hello World' }

Subscribe to the topic some-topic and receive messages whenever a new message has been published:

const messaging = await cds.connect.to('messaging') 
messaging.on('some-topic', (message) => console.log(message.data)) 

Kafka-specifc functionality

Topics and events types

By default, cds-kafka expects the name of the Kafka topic and the event type to be the same. As an example, sending an event my/custom/event to Kafka, would result in a topic with the same name to be created and used by CAP. However, there are possibilities to diverge from this rule and it is also possible to simply route all event types to a single topic or create a wild mix of topics and event types. To still have all the important information at hand, cds-kafka will add two headers to each message, containing the event and topic name:

  • x-sap-cap-event: Contains the name of the event in CAP.
  • x-sap-cap-kafka-topic: Indicates the actual Kafka topic from which the message originated.

This information can simply be accessed by inspecting the message headers.


// Sending a message with different topic and event
await messaging.emit({
    event: 'my/custom/event',
    data: { subject: 'Hello World' },
    headers: {
      '@kafka.topic': 'some-generic-topic',
    }
});

// Subscring to the event
messaging.on("my/custom/event", (message) => {
  console.log(message.headers["x-sap-cap-event"]) // => my/custom/event
  console.log(message.headers["x-sap-cap-kafka-topic"]) // => some-generic-topic
})
Subscribing to topics via Regular Expressions or catch-all (*)

cds-kafka is allowing subscriptions to multiple topics using regular expressions. Regular expressions enable subscribing to multiple topics with matching patterns. Since CAP’s internal API only supports string-based subscriptions, the two additional headers (see above) are used to track the information:

  • x-sap-cap-event: Contains the registered regular expression.
  • x-sap-cap-kafka-topic: Indicates the actual Kafka topic from which the message originated.

It's important to note, that regex-based subscriptions only work for already existing topics at the time of subscription. If a new matching topic is added after the application has started, the application must be restarted to receive messages from this topic.

Next to regular expressions, there is also support for a catch-all subscription which allows listening to all topics of a broker, excluding Kafka’s private ones (those starting with __). Internally, a regex subscription is created to match all public topics dynamically.

The following snippet shows how both options can be used:

// Subscribe all topics matching the pattern (e.g. topic-A-1, topic-B-1...) 
messaging.on(/topic-(A|B|C)-.*/i, (message) => console.log(message))

// Subscribe all topics (excluding the Kafka private ones starting with __)
messaging.on("*", (message) => console.log(message))
Using CloudEvents

CAP has native support for the CloudEvents specification (see documentation). By setting the message format to cloudevents supporting metadata will be added to all messages. cds-kafka also supports CloudEvents adhering to the official CloudEvents specification for Apache Kafka. While the specification distinguishes between wrapping the message data and adding headers, cds-kafka enables both at the same time. The reasons for this is, that CAP internally takes care of CloudEvents metadata and the incoming message is already stripped of all CloudEvents metadata. Because this metadata might be required, the header data will still be available when processing the incoming message.

The following example shows an inspection of a message in the event handler. The CloudEvents header fields (prefixed with ce-) are still visible and can be read programatically.

{
  "data": { "subject": "Hello World" },
  "headers": {
    "ce-specversion": "1.0",
    "ce-id": "df396250-cb0d-4f88-97c4-0aa25faa12ef",
    "ce-type": "some-topic",
    "ce-source": "cap-kafka-example-app-1",
    "ce-time": "2025-01-02T15:59:24.265Z",
    "ce-datacontenttype": "application/json",
  },
  "event": "some-topic"
}
Specifying topic, key and partition when emitting a message

When emitting a message with cap-kafka, the default behavior is to send the message to a random partition, with the event name used as the topic. However, this behavior can be customized to suit more complex architectural needs. The following custom headers can be used to override the default behavior:

  • @kafka.key: Assign a key to the message for logical grouping or ordering purposes. For example, all messages related to a specific entity can use the same key, ensuring they are processed in the same order.
  • @kafka.partition: Specify a specific partition to which the message should be sent. This is useful for advanced use cases requiring precise control over partition distribution.
  • @kafka.topic: Override the default topic name (derived from the event name) and specify a custom topic. This enables routing messages to different topics based on dynamic conditions.

The following example show how those headers can be set. If set, those headers will not be sent to Kafka, but only used internally for applying the specific behavior.

await messaging.emit({
   event: 'ObjectCreated',
   data: { subject: 'Hello World' },
   headers: {
     '@kafka.key': '1234',
     '@kafka.partition': "0",
     '@kafka.topic': 'cap.test.object.created.v1',
   }
});

While the @kafka headers are only used internally, every message consumed by cds-kafka (even those not using the @kafk headers) will receive a set of additional headers providing information on Kafka internals. Next to the already described x-sap-cap-kafka-topic, the following header fields are available:

  • x-sap-cap-kafka-partition: Contains the information of the partition the message has been retrieved from.
  • x-sap-cap-kafka-offset: Contains the offset within the partition the message has been retrieved from.
  • x-sap-cap-kafka-timestamp: Contains the timestamp the message has been stored inside Kafka.

These capabilities allow cap-kafka to support more sophisticated setups, such as architectures with specific partitioning strategies or dynamic topic routing, while not breaking CAP’s internal APIs.

TODO

  • Switch from KafkaJS to @confluentinc/kafka-javascript
  • Look into confluent schema registry
  • Add test suite
MIT, read

History

Latest

v0.1.4

  1. v0.1.3

  2. v0.1.2

  3. v0.1.1

  4. v0.1.0

  5. v0.0.1

On npm
30downloads per week, npm
Weekly downloads for cds-kafka26 complete calendar weeks from 2026-04-27 to 2026-10-25; the latest total is 30.27 Apr – 3 May: 6724 May – 10 May: 42611 May – 17 May: 32118 May – 24 May: 56925 May – 31 May: 5021 Jun – 7 Jun: 2828 Jun – 14 Jun: 18615 Jun – 21 Jun: 18822 Jun – 28 Jun: 22929 Jun – 5 Jul: 2116 Jul – 12 Jul: 28913 Jul – 19 Jul: 34520 Jul – 26 Jul: 28627 Jul – 2 Aug: 2933 Aug – 9 Aug: 21310 Aug – 16 Aug: 21717 Aug – 23 Aug: 20124 Aug – 30 Aug: 23731 Aug – 6 Sept: 2217 Sept – 13 Sept: 13014 Sept – 20 Sept: 10421 Sept – 27 Sept: 13528 Sept – 4 Oct: 1985 Oct – 11 Oct: 18612 Oct – 18 Oct: 6419 Oct – 25 Oct: 30
Declared alternative
  1. @cap-js-community/event-queueTransactional processing of asynchronous and periodic CAP events
Event Mesh
  1. SAP Integration Suite, advanced event meshEvent streaming and management platform in Integration Suitefrom BTP/BAIP
  2. SAP Cloud Application Event HubDistributes business events between SAP cloud applicationsfrom BTP/BAIP
  3. Event MeshManaged queues and topics over AMQP, MQTT and RESTfrom BTP/BAIP
  4. SAP Integration Suite, Event MeshEvent broker inside SAP Integration Suitefrom BTP/BAIP
  5. com.sap.cds:cds-feature-advanced-event-meshCAP Java plugin for SAP Integration Suite, advanced event meshfrom CAP
  6. com.sap.cds:cds-feature-enterprise-messagingConnects CAP Java messaging to SAP Event Meshfrom CAP
  7. com.sap.cds:cds-feature-event-hubConnects CAP Java messaging to SAP Cloud Application Event Hubfrom CAP
  8. com.sap.cds:cds-feature-kafkaConnects CAP Java messaging to Apache Kafkafrom CAP
  9. com.sap.cds:cds-feature-redisBeta connector from CAP Java messaging to Redis Pub/Subfrom CAP
  10. com.sap.cds:cds-services-bomMaven bill of materials pinning CAP Java module versionsfrom CAP
  11. @cap-js/advanced-event-meshCAP integration with SAP Integration Suite advanced event meshfrom CAP
  12. @cap-js/asyncapiExports AsyncAPI documents for a CAP service's eventsfrom CAP
  13. @cap-js/event-brokerConsumes events from SAP Cloud Application Event Hub in CAPfrom CAP
  14. cesar-sap/abap_kafka_rest_proxyABAP connector to Kafka through the Confluent Kafka REST Proxyfrom ABAP
  15. cds-event-monitoringStores, browses and resends messages a CAP service receivesfrom CAP
  16. gregorwolf/AWS_SNS4ABAPICF handler receiving Amazon SNS notifications in an ABAP systemfrom ABAP
  17. INVIXO/abapMQMQTT 3.1.1 client implemented in ABAPfrom ABAP
  18. MQBAMQTT publish/subscribe in ABAP with an external broker bridgefrom ABAP
  19. @sap/cdsCAP Node.js runtimefrom CAP

Details

Sources5
npm registrydiscovered herechecked
awesome-capdiscovered herechecked
npm registry, cds-kafkaversion, releases, installschecked
github.com/git+https://github.com/mikezaschka/cds-kafka.gittree, pushes, contributors, CIchecked
readme.mdquoted, and what the entry declareschecked

Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.

Compatibility and provenance
runtimesnode
declared for>=7
deploymentCloud Foundry, local
latestv0.1.4
first release
releases and cadence6, ~1d median
discovered vianpm registry, awesome-cap
first seen in the atlas
ecosystem and domaincap, integration-and-messaging
History in the atlas8
  1. Re-read against the README and the maintainer's own two SAP Community posts. Every claim in all three is about emitting to and consuming from a broker; none describes deferred work, retries or periodic scheduling, and async processing's own description separates itself from messaging. Event Mesh is the concern that covers the mapping between a CDS event and a broker topic, and its CAP coverage already states that non-SAP brokers are what plugins add. The CAP Java counterpart, com.sap.cds:cds-feature-kafka, carries the same edge.
  2. The README names the broker and the client library it reaches it through, and the edge was missing while cds-nats, the sibling broker adapter, already carried its own.
  3. cds-kafka 0.1.4 declares @sap/cds >=7 as a peer dependency in its npm record. Checked 2026-09-19 against the registry.
  4. cf, local
  5. Stated in the README's licensing section and in the npm record. It sits beside the SAP Developer License relation rather than replacing it: the package is MIT, the use inside an SAP Cloud Application is what the other instrument speaks to.
  6. written from the README and the maintainer's two SAP Community posts
  7. cds-kafka required Apache Kafka as its broker; the connection says what the dependency could not: that messages run both ways, to and from topics.
  8. First seen.
For your agent