Setup a runtime
Overview
Runtime connects to a Zeebe instance and listens to service tasks handled by the connectors.
Runtime does not discover connectors automatically. You need to let runtime know which connectors you want it to handle by passing connector classes through outbound_connectors
argument.
from pydantic import BaseModel, Field
from loguru import logger
from python_camunda_sdk import OutboundConnector
class StatusModel(BaseModel):
status: str
class LogConnector(OutboundConnector):
message: str = Field(description="Message to log")
async def run(self) -> StatusModel:
logger.info(f"LogConnector: {self.message}")
return StatusModel(status="ok")
class ConnectorConfig:
name = "LogConnector"
type = "log"
Start the runtime with
$ python example/runtime.py
2023-08-03 20:44:09.887 | INFO | python_camunda_sdk.runtime.runtime:main:114 - Loading LogConnector (log)
2023-08-03 20:44:09.887 | INFO | python_camunda_sdk.runtime.runtime:main:117 - Starting runtime
Runtime has successfully started and loaded LogConnector
. It is now ready to handle 'log' type service tasks.
Configuration
In addition to outbound_connectors
you need to give runtime credentials to Zeebe instance.
With config object
You can pass configuration object with the details of Zeebe instance you want to connect. The examples of supported configs are below.
With environmental variables
If you don't pass config to the runtime, it will try to collect connection configuration from the environmental variables specified below.
Variable | Description |
---|---|
CAMUNDA_CONNECTION_TYPE |
Connection type |
Connection type value | Description |
---|---|
INSECURE | Insecure connection to a self-hosted Zeebe |
SECURE | Secure connection to a self-hosted Zeebe |
CAMUNDA_CLOUD | Conneection to Camunda Cloud |
Variable | Description |
---|---|
ZEBEE_HOSTNAME |
Hostname or IP address of Zeebe |
ZEBEE_PORT |
The port Zeebe is listening on |
Variable | Description |
---|---|
ZEBEE_HOSTNAME |
Hostname or IP address of Zeebe |
ZEBEE_PORT |
The port Zeebe is listening on |
SSL_ROOT_CA |
SSL certificate |
SSL_PRIVATE_KEY |
SSL private key |
SSL_CERTIFICATE_CHAIN |
SSL certificate chain |
Variable | Description |
---|---|
CAMUNDA_CLIENT_ID |
Client id |
CAMUNDA_CLIENT_SECRET |
Client seecret |
CAMUNDA_CLUSTER_ID |
Camunda cluster id |
CAMUNDA_REGION |
Camunda cluster region |