mirror of https://github.com/dapr/docs.git
2.3 KiB
2.3 KiB
| type | title | linkTitle | description |
|---|---|---|---|
| docs | Kafka binding spec | Kafka | Detailed documentation on the kafka binding component |
Setup Dapr component
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
namespace: <NAMESPACE>
spec:
type: bindings.kafka
version: v1
metadata:
- name: topics # Optional. in use for input bindings
value: topic1,topic2
- name: brokers
value: localhost:9092,localhost:9093
- name: consumerGroup
value: group1
- name: publishTopic # Optional. in use for output bindings
value: topic3
- name: authRequired # Required. default: "true"
value: "false"
- name: saslUsername # Optional.
value: "user"
- name: saslPassword # Optional.
value: "password"
topicsis a comma separated string of topics for an input binding.brokersis a comma separated string of kafka brokers.consumerGroupis a kafka consumer group to listen on.publishTopicis the topic to publish for an output binding.authRequireddetermines whether to use SASL authentication or not.saslUsernameis the SASL username for authentication. Only used ifauthRequiredis set to -"true".saslPasswordis the SASL password for authentication. Only used ifauthRequiredis set to -"true".
{{% alert title="Warning" color="warning" %}} The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described [here]({{< ref component-secrets.md >}}). {{% /alert %}}
Specifying a partition key
When invoking the Kafka binding, its possible to provide an optional partition key by using the metadata section in the request body.
The field name is partitionKey.
Example:
curl -X POST http://localhost:3500/v1.0/bindings/myKafka \
-H "Content-Type: application/json" \
-d '{
"data": {
"message": "Hi"
},
"metadata": {
"partitionKey": "key1"
},
"operation": "create"
}'
Output Binding Supported Operations
- create
Related links
- [Bindings building block]({{< ref bindings >}})
- [How-To: Trigger application with input binding]({{< ref howto-triggers.md >}})
- [How-To: Use bindings to interface with external resources]({{< ref howto-bindings.md >}})
- [Bindings API reference]({{< ref bindings_api.md >}})