Skip to main content

Overview

Provides functions to read messages from Kafka brokers including the IBM Event Streams cloud service as a stream and submit tuples to Kafka brokers as messages.

The broker configuration must be done with properties in an application configuration or by using a dictionary variable. The minimum set of properties must contain the bootstrap.servers configuration, which is valid for both consumers and producers, i.e. for the KafkaConsumer and KafkaProducer classes.

It is also possible to use different application configurations for consumer and producer when special consumer or producer configs must be used.

Sample

A simple hello world example of a Streams application publishing to a topic and the same application consuming the same topic:

from streamsx.topology.topology import Topology
from streamsx.topology.schema import CommonSchema
from streamsx.topology.context import submit, ContextTypes
from streamsx.kafka import KafkaConsumer, KafkaProducer
import time

def delay(v):
    time.sleep(5.0)
    return True

topology = Topology('KafkaHelloWorld')

to_kafka = topology.source(['Hello', 'World!'])
to_kafka = to_kafka.as_string()
# delay tuple by tuple
to_kafka = to_kafka.filter(delay)

# Publish a stream to Kafka using TEST topic, the Kafka server is at localhost
producer = KafkaProducer(config={'bootstrap.servers': 'localhost:9092'},
                         topic='TEST')
to_kafka.for_each(producer)

# Subscribe to same topic as a stream
consumer = KafkaConsumer(config={'bootstrap.servers': 'localhost:9092'},
                         schema=CommonSchema.String,
                         topic='TEST')
from_kafka = topology.source(consumer)

# You'll find the Hello World! in stdout log file:
from_kafka.print()

submit(ContextTypes.DISTRIBUTED, topology)
# The Streams job is kept running.

Documentation

Release files for streamsx.kafka 1.10.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for streamsx.kafka 1.10.2
File Size Uploaded
streamsx.kafka-1.10.2.tar.gz 26.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for streamsx.kafka 1.10.2
File Interpreter ABI Platform
streamsx.kafka-1.10.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 55.9 kB

Release files / streamsx.kafka-1.10.2.tar.gz

Download URL streamsx.kafka-1.10.2.tar.gz
Size 26.6 kB
Tags Source
SHA-256 checksum
How to use checksums
89ba7ab8d58e605fd8be03149b060b73c9ee6925e856229259cba704bba8136a
BLAKE2b-256 checksum
How to use checksums
f9f2a5a5cdf7c470b76d4759018698a6d8b27cb89e83d4804af403fbd30b1907
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.6

Release files / streamsx.kafka-1.10.2-py2.py3-none-any.whl

Download URL streamsx.kafka-1.10.2-py2.py3-none-any.whl
Size 29.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
5d4af53154be844010172d5c28387e92a8aab85f234eb164f9328405333bf78e
BLAKE2b-256 checksum
How to use checksums
65023883b80e7920bb9d220656f94ea3406f62d9722de7ee7a3f4dc1b6452b5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.6

Release history Release notifications | RSS feed

This release

1.10.2 This release

2 release files

1.10.1

2 release files

1.10.0

2 release files

1.9.0

2 release files

1.8.1

2 release files

1.7.0

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.4

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page