Trigger functions from Kafka¶
Trigger function invocations from messages received on Kafka topics.
Note: This feature is included for OpenFaaS Pro customers.
Installation¶
You can install the Kafka connector using its helm chart, or by using arkade.
Are you an Aiven customer? See also: Event-driven OpenFaaS with Managed Kafka from Aiven
Installation with arkade¶
export TOPICS="payment.created"
arkade install kafka-connector \
--broker-host kafka-broker \
--topics $TOPICS \
--license-file $HOME/.openfaas/LICENSE
Installation with Helm¶
See helm chart
Usage¶
Once you have configured a number of topics, you can then annotate your functions so that they get triggered by any incoming messages on those topics.
Create a new function:
export OPENFAAS_PREFIX=ghcr.io/openfaas
faas-cli new --lang go provision-customer
Now add an annotation for the payment.created
topic, so that the provision-customer
function is invoked for any message received:
version: 1.0
provider:
name: openfaas
gateway: http://127.0.0.1:8080
functions:
provision-customer:
annotations:
topic: payment.created
lang: go
handler: ./provision-customer
image: ghcr.io/openfaas:provision-customer
Now deploy your function, and publish an event to your Kafka broker on the payment.created
topic.
See also¶
- Event-driven OpenFaaS with Managed Kafka from Aiven
- Quick start with the Helm chart - self-hosted, SASL and TLS Client Certificates
- Launch blog post: Staying on topic: trigger your OpenFaaS functions with Apache Kafka
Would you like a demo?¶
Feel free to reach out to us for a demo or to ask any questions you may have.