Note |
---|
This doc should be moved to github as part of https://github.com/openedx/openedx-events/issues/238. |
...
[Kafka specific] Make sure your code is running in an environment that has the
confluent_kafka
library installed along with itsavro
andschema-registry
extras. See https://github.com/openedx/event-bus-kafka/blob/main/docs/decisions/0005-optional-import-of-confluent-kafka.rst for why this has to be done separately.For local development, you can simply exec into the relevant container and run
pip install confluent_kafka[avro,schema-registry]
Once you make sure
confluent_kafka[avro,schema-registry]
is available you can add theopenedx-events
andedx-event-bus-kafka
as you would any other dependency.
For Redis implementation:Anchor Add-required-Redis-config Add-required-Redis-config Code Block language yaml # This tells openedx-events which library to use to create the event producer. # This allows us to plug in different implementations EVENT_BUS_PRODUCER: edx_event_bus_redis.create_producer # This tells openedx-events which library to use to create the event consumer. EVENT_BUS_CONSUMER: edx_event_bus_redis.RedisEventConsumer EVENT_BUS_REDIS_CONNECTION_URL: redis://:password@edx.devstack.redis:6379/' EVENT_BUS_TOPIC_PREFIX: dev
For Kafka implementation:Anchor Add-required-Kafka-config Add-required-Kafka-config Code Block language yaml EVENT_BUS_KAFKA_SCHEMA_REGISTRY_URL EVENT_BUS_KAFKA_BOOTSTRAP_SERVERS # This tells openedx-events which library to use to create the event producer. # This allow us to plug in different implementations EVENT_BUS_PRODUCER: edx_event_bus_kafka.create_producer # This tells openedx-events which library to use to create the event consumer. EVENT_BUS_CONSUMER: edx_event_bus_kafka.KafkaEventConsumer #### If using an auth-restricted broker ##### EVENT_BUS_KAFKA_SCHEMA_REGISTRY_API_KEY: 'MY_SR_KEY' EVENT_BUS_KAFKA_SCHEMA_REGISTRY_API_SECRET: 'MY_SR_SECRET' EVENT_BUS_KAFKA_API_KEY: 'MY_KEY' EVENT_BUS_KAFKA_API_SECRET: 'MY_SECRET'
We also strongly recommend using a topic prefix to distinguish between environments, eg ‘dev’, ‘stage’, or ‘prod.’ This prefix will be added to all topic names when both producing and consuming. Adding a topic prefix will reduce the likelihood of accidentally conflating data from different environments. To add a topic prefix, use the
EVENT_BUS_TOPIC_PREFIX
setting.
Producing a signal
As of openedx-events 9.0.0 version, producing a signal to event bus is possible by just adding below settings to the host application and including openedx_events
in INSTALLED_APPS
setting.
...
Add additional private docs as-needed
2U: Supplementary how-to for event bus for edx.org (private link)