mirror of https://github.com/knative/docs.git
key deserializer doc for kafka source (#2140)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
This commit is contained in:
parent
c3019c2561
commit
8890fb6f5a
|
@ -221,3 +221,34 @@ You must ensure that you meet the [prerequisites listed in the Apache Kafka over
|
||||||
$ kubectl delete -f kafka/source/samples/kafka-topic.yaml
|
$ kubectl delete -f kafka/source/samples/kafka-topic.yaml
|
||||||
kafkatopic.kafka.strimzi.io "knative-demo-topic" deleted
|
kafkatopic.kafka.strimzi.io "knative-demo-topic" deleted
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## (Optional) Specify the key deserializer
|
||||||
|
|
||||||
|
When `KafkaSource` receives a message from Kafka, it dumps the key in the Event extension called `Key` and dumps Kafka message headers in the extensions starting with `kafkaheader`.
|
||||||
|
|
||||||
|
You can specify the key deserializer among four types:
|
||||||
|
|
||||||
|
* `string` (default) for UTF-8 encoded strings
|
||||||
|
* `int` for 32-bit & 64-bit signed integers
|
||||||
|
* `float` for 32-bit & 64-bit floating points
|
||||||
|
* `byte-array` for a Base64 encoded byte array
|
||||||
|
|
||||||
|
To specify it, add the label `kafkasources.sources.eventing.knative.dev/key-type` to the `KafkaSource` definition like:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
apiVersion: sources.eventing.knative.dev/v1alpha1
|
||||||
|
kind: KafkaSource
|
||||||
|
metadata:
|
||||||
|
name: kafka-source
|
||||||
|
labels:
|
||||||
|
kafkasources.sources.eventing.knative.dev/key-type: int
|
||||||
|
spec:
|
||||||
|
consumerGroup: knative-group
|
||||||
|
bootstrapServers: my-cluster-kafka-bootstrap.kafka:9092 #note the kafka namespace
|
||||||
|
topics: knative-demo-topic
|
||||||
|
sink:
|
||||||
|
ref:
|
||||||
|
apiVersion: serving.knative.dev/v1
|
||||||
|
kind: Service
|
||||||
|
name: event-display
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in New Issue