- Added support for python3.12
- Removed the support for python3.8
- Monitoring: Add a custom attribute,
kafka_received_message
to track whether a message was processed or not.
- Monitoring: Ensure that we have a root span for each iteration of the consume loop; renamed the trace name to be
consumer.consume
.
- Dropped Support for Django 3.2, Django 4.0 and Django 4.1
- Added Support for Python 3.12
- Added client.id to base configuration.
- Reset edx-django-utils RequestCache before handling each event
- Changed ordering of certain context assignments in producer code.
- Adds custom exceptions for producing and consuming errors.
- Constrain openedx-events version to at least 8.5.0 (for EventsMetadata serialization support)
- Added event_metadata_as_dict to ProducingContext for easier replay from logs
- Added event_data_as_dict to ProducingContext for easier replay from logs
- Reconfigured serializers to use topic_record_name_strategy, allowing multiple event types per topic
- BREAKING CHANGE: Removed deprecated
signal
argument from consumer initialization
- Added
signal
back as an argument when creating a consumer for compatibility with the openedx-events API
- Implement openedx-events Event Bus Consumer API.
- BREAKING CHANGE: Remove
consume_events
management command as this command will be provided by openedx_events. To replay events using the openedx-events version of the management command, pass--extra '{"offset_time": "2023-01-08T06:46:22"}'
instead of-o 2023-01-08T06:46:22
. - BREAKING Change:
offset_timestamp
argument has been removed fromconsume_indefinitely
andreset_offsets_and_sleep_indefinitely
methods. It is now added as an optional argument namedoffset_time
toKafkaEventConsumer
constructor.
- Switch from
edx-sphinx-theme
tosphinx-book-theme
since the former is deprecated - Refactored consumer to manually deserialize messages instead of using DeserializingConsumer
- Make signal argument optional in consumer command (take signal from message headers)
- Add function tracing to the event consumption workflow for better monitoring.
consume_events
command now loads all public signals so that the consumer can load signals byevent_type
even if their modules were not already imported
- produce_event management command fixed to pass required events_metadata parameter
- Include
message_id
in audit log when message is produced (wasNone
)
- Added documentation to all Django settings used in consumer and producer
There was no version 3.9.0, due to a release issue. (Ignore any v3.9.0
tag.)
- Added logging of successful message production, consumption, and processing (not just errors)
- Require and use openedx-events 5.0.0, which has a breaking API change that affects event bus consumers.
- Producer now passes all metadata fields as headers
- Consumer emits events with the original metadata information (from the producer)
- Consumer management command exits with useful error message if confluent-kafka library not available.
- Added
reset_offsets_and_sleep_indefinitely
method to consumer; relying code should switch to calling this when an offset timestamp is set. - Deprecated the
offset_timestamp
parameter on the consumer'sconsume_indefinitely
method, sincereset_offsets_and_sleep_indefinitely
should be used instead.
- In the consumer loop, open new database connection if the old one has closed before processing messages
- Reset mode now commits the correct offsets to Kafka.
- Added a poll call to force resets to be processed during replay/offset-reset mode.
- Consumers do not consume events after resetting offsets.
- Convert timestamps to millisecond offsets as expected by the Kafka API when replaying by timestamp in the consumer
- New setting
EVENT_BUS_KAFKA_CONSUMER_CONSECUTIVE_ERRORS_LIMIT
will terminate the consumer if too many errors occur in a row, supporting an automated version of "have you tried turning it off and on again" (as long as consumer will automatically be restarted e.g. by Kubernetes).
- Fixed bugs in the event replay/offset handling code for consumers.
- Kill infinite consumer loop when we see a fatal KafkaError, as recommended in the documentation. See https://github.com/confluentinc/librdkafka/blob/e0b9e92a0b492b5b1a6f1bcf08744928d45bf396/INTRODUCTION.md#fatal-consumer-errors.
- Added/removed some custom attributes used for monitoring. Search for custom_attribute_name annotations for details.
- Add timestamp parameter for consumer, allowing the starting offset for consuming to be overridden from the default.
- A variety of custom attributes are now set for monitoring purposes. Search for custom_attribute_name annotations for details.
- Error recording to the log will now include message details when the message is available on the error.
- BREAKING CHANGE: Make event_metadata parameter required
- Set CloudEvent headers on events using an optional event_metadata parameter
- Implement openedx-events Event Bus Producer API
- BREAKING CHANGE: Remove caching from
get_producer
and rename tocreate_producer
, as we now rely on the wrapper in openedx-events to cache that call
Upgrading library from 1.x:
- Replace calls to
edx_event_bus_kafka.get_producer
withopenedx_events.event_bus.get_producer
- Add Django setting
EVENT_BUS_PRODUCER = "edx_event_bus_kafka.create_producer"
These breaking changes are only relevant for the producing side. (This should only include the CMS at the moment.)
- Improve receiver error log message -- mention that stack traces are elsewhere in log
- Log and record receiver errors the same way as other errors (with offset, partition, etc.)
- Commit consumer offset asynchronously
- Consumer logs a warning for receivers that fail with an exception
- Manually manage commits instead of using auto-commit on the consumer
- Catch Exception instead of BaseException on both producer and consumer
- Enhanced error logging in consumer, including telemetry for exceptions
- Consumer loop will no longer exit when an error is encountered
- Log full event data on all producer errors
- Upgrade openedx-events and fastavro to bring in a fix for schema creation
- Removed proof-of-concept code that logged user-login events
- Correct and clarify management command help strings (some copy-paste errors)
- Update TODO comments
- Remove override of auto.offset.reset on consumer (which will default to "latest"). New consumer groups will consume only messages that are sent after the group was initialized.
- Remove redundant lookup of signal in consumer loop (should not have any effect)
- Explicitly encode message header values as UTF-8 (no change in behavior)
- Upgrade openedx-events. When AvroSignalSerializer gets event schemas, it will get whatever is currently defined in openedx-events, so this will update the COURSE_CATALOG_EVENT_CHANGED schema (dropping effort field)
EVENT_BUS_KAFKA_CONSUMERS_ENABLED
now defaults to True instead of False- Removed manual monitoring since New Relic tracks these now.
- Added monitoring for consumption tasks.
- Fixed bug in schema registry that was sending schemas to the wrong topic
- Bump version to 1.x to acknowledge that this is in use in production
- Breaking changes
EventProducerKafka
is nowKafkaEventProducer
- KafkaEventConsumer is now part of the public API
- Topic names can be autoprefixed by setting
EVENT_BUS_TOPIC_PREFIX
- Producer now polls on an interval, improving callback reliability. Configurable with
EVENT_BUS_KAFKA_POLL_INTERVAL_SEC
.
- Breaking change: Public API is now defined in
edx_event_bus_kafka
package andedx_event_bus_kafka.management.commands
package; all other modules should be considered unstable and not for external use.
- Various lint issues (and missing
__init__.py
files.)
- Breaking changes in the producer module, refactored to expose a better API:
- Rather than
send_to_event_bus(...)
, relying code should now callget_producer().send(...)
. - The
sync
kwarg is gone; to flush and sync messages before shutdown, callget_producer().prepare_for_shutdown()
instead.
- Rather than
- Clarify that config module is for internal use only.
- Implementation changes: Only a single Producer is created, and is used for all signals.
- Fixed bug in test module for when confluent-kafka isn't present
- Never evict producers from cache. There wasn't a real risk of this, but now we can rely on them being long-lived. Addresses remainder of #16.
- Properly load auth settings for producer/consumer. (Auth settings were ignored since 0.3.1.)
- Remove confluent-kafka as a formal dependency of the repository.
- Note: This library will not work without confluent-kafka.
- Add an ADR to explain why this work was done.
- Rename settings to have consistent prefix.
KAFKA_CONSUMERS_ENABLED
becomesEVENT_BUS_KAFKA_CONSUMERS_ENABLED
CONSUMER_POLL_TIMEOUT
becomesEVENT_BUS_KAFKA_CONSUMER_POLL_TIMEOUT
- Updates to documentation and tests for various settings previously renamed
- Refactored consumer to use common configuration.
- Moved configuration onto separate file.
- Updated configuration settings to have EVENT_BUS_KAFKA prefix.
- Cache producers so that they don't lose data.
- First release on PyPI.