Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

benzene-kafka

Host Benzene Python handlers on Apache Kafka — a self-hosted consumer and a Kafka-produce outbound client — the same handlers, no rewrite. Depends only on benzene-core.

pip install benzene-kafka             # the binding + testing helpers
pip install "benzene-kafka[kafka]"    # + confluent-kafka for the real clients
from benzene.core import application_from, build_application
from benzene.kafka import KafkaConsumerApp, KafkaMessageSender, run_consumer_loop

# Inbound: one record -> one pipeline invocation -> one scope; ack/log, no reply.
definition, _ = build_application(OrdersStartUp)
app = KafkaConsumerApp(application_from(definition))
await run_consumer_loop(app, consumer)          # consumer: a confluent_kafka.Consumer

# Outbound: publish to a Kafka topic, Benzene topic carried in the `topic` header.
sender = KafkaMessageSender("orders-events", bootstrap_servers="localhost:9092")
await sender.send_message("orders:created", order, headers={"x-correlation-id": "abc"})
  • Consumer — the Benzene topic comes from the record's topic header (the cross-port convention); the other Kafka headers are the Benzene headers (UTF-8), the value is the JSON body. One record is one scope; there is no response channel, so the result is acknowledge/log only — run_consumer_loop commits the offset on success (at-least-once) and leaves a failed record for redelivery. A poison record can never crash the loop.
  • OutboundKafkaMessageSender implements the benzene.core.MessageSender port over confluent-kafka (optional extra), forwarding the header dictionary onto the record's Kafka headers so correlation/trace propagation rides across the hop.

The binding is duck-typed against confluent-kafka, so decode, dispatch, and send are exercised in memory with fakes — no broker, no SDK. Test through benzene.kafka.testing (a native-record builder + a test host) or the shared harness (create_test_host(StartUp).build_kafka() + send_kafka) — see the runnable examples/kafka_orders/. Mirrors .NET's Benzene.Kafka.Core, and contributes the benzene.kafka subpackage to the shared benzene namespace.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

benzene_kafka-0.1.0b1.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

benzene_kafka-0.1.0b1-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file benzene_kafka-0.1.0b1.tar.gz.

File metadata

  • Download URL: benzene_kafka-0.1.0b1.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for benzene_kafka-0.1.0b1.tar.gz
Algorithm Hash digest
SHA256 9693d23452d9a16fb4dc0843a4ec47f3a38e0fc3e75266e0e5ebc20515aa6174
MD5 2aeb564e2e5ee4a6395e3e68dde9df57
BLAKE2b-256 c5eb4665c3f3b0a3f27c4e4a2040c2e1cb5e562eb79adcdd9efe30f39f07009e

See more details on using hashes here.

Provenance

The following attestation bundles were made for benzene_kafka-0.1.0b1.tar.gz:

Publisher: release.yml on daniellepelley/benzene-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file benzene_kafka-0.1.0b1-py3-none-any.whl.

File metadata

  • Download URL: benzene_kafka-0.1.0b1-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for benzene_kafka-0.1.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 977e9138ce13dc478e720644b6aae2ade3e6f8ab9b554fc2231eff1c5318b288
MD5 ba10c56729846b1639a0456fcb30cc8a
BLAKE2b-256 bdacf5edc453116a205ed02b5c74be9bac938b0006fdb327df82638573b04a8d

See more details on using hashes here.

Provenance

The following attestation bundles were made for benzene_kafka-0.1.0b1-py3-none-any.whl:

Publisher: release.yml on daniellepelley/benzene-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0b1 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page