You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/openfaas-pro/kafka-events.md
+22-8Lines changed: 22 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ The topics you need to connect to functions are set on a connector.
27
27
28
28
A single connector can have either a single topic, or a comma-separated list of topics.
29
29
30
-
Customers tend to prefer to deploy a single copy of the connector for each topic, so that they can be scaled to match the number of consumers set on the partition.
30
+
It is recommended to deploy one connector per topic, so that it can be scaled to match the number of consumers set on the partition. I.e. a topic named `payment.created` which has a partition size of 3, should have three replicas of the configured connector deployed.
31
31
32
32
But it's also possible to use a single connector and pass in multiple topics i.e. `payment.created,customer.onboarded,invoice.generate`.
33
33
@@ -36,8 +36,8 @@ Your function(s) can then subscribe to one or more topics by setting the topic a
36
36
Create a new function:
37
37
38
38
```bash
39
-
export OPENFAAS_PREFIX=ghcr.io/openfaas
40
-
faas-cli new --lang go provision-customer
39
+
export OPENFAAS_PREFIX=docker.io/alexellis2
40
+
faas-cli new --lang golang-middleware provision-customer
41
41
```
42
42
43
43
Now add an annotation for the `payment.created` topic, so that the `provision-customer` function is invoked for any message received:
Now deploy your function, and publish an event to your Kafka broker on the `payment.created` topic.
@@ -71,17 +71,31 @@ For headers and metadata:
71
71
* `X-Kafka-Offset` - the offset in Kafka that the message was received on
72
72
* `X-Kafka-Key` - if set on the message, the key of the message in Kafka
73
73
74
-
The default content-type is configured as `text/plain`, but can be changed to another content-type such as `application/json` or `application/octet-stream` by the [values.yaml file](https://github.com/openfaas/faas-netes/blob/master/chart/kafka-connector/values.yaml) for the connector.
74
+
If a binary message key is submitted to a Kafka topic, then the value will be base64-encoded and passed to the function as the `X-Kafka-Key` header, along with an additional header `X-Kafka-Key-Enc` with a value of `b64` to indicate that the value is base64-encoded.
75
75
76
-
Most templates make these variables available through their request or context object, for example:
76
+
The connector will invoke functions using the default content type of `text/plain`, however [this can be overridden in the Helm chart](https://github.com/openfaas/faas-netes/blob/master/chart/kafka-connector/values.yaml) to i.e. `application/json or whatever is required.
77
+
78
+
Most templates make HTTP headers sent by the connector available through their request or context object, for example:
77
79
78
80
* [golang-middleware](/languages/go/)
79
81
* [python3-http](/languages/python/)
80
82
* [node22](/languages/node/)
81
83
82
84
For detailed examples with Node.js, see: [Serverless For Everyone Else](http://store.openfaas.com/l/serverless-for-everyone-else)
83
85
84
-
For detailed examples with Go, see: [Everyday Golang (Premium Edition)](https://openfaas.gumroad.com/l/everyday-golang)
86
+
For detailed examples with Go, see: [Everyday Golang (Premium Edition only)](https://openfaas.gumroad.com/l/everyday-golang)
87
+
88
+
### Message lifecycle and retries
89
+
90
+
**Default synchronous invocation**
91
+
92
+
By default, the Kafka connector will invoke functions using the Gateway's synchronous invocation endpoint. If a response is returned by a function, then the message will be considered as processed and will be acknowledged on the topic.
93
+
94
+
**Automatic retries via the queue-worker**
95
+
96
+
If you would like to retry messages then you can switch the connector to use asynchronous invocations. Asynchronous invocations are executed using the queue-worker.
97
+
98
+
The queue-worker has a set of default retry values set via the Helm chart. They can also be overridden for each function using the documentation on the [Retries page](/openfaas-pro/retries).
0 commit comments