Skip to main content

Event broker built on top of kafka and rabbitmq; used to handle micro services message exchange.

Project description

# Franz

A lite wrapper around [Kafka]( and [RabbitMQ](

# Usage

## Installation
- `pip install franz` (recommended)
- `pip -e`
- Change `@master` to a version or commit if required.

## RabbitMQ
### Sending a message
import random
import time

import franz

class FranzData(franz.FranzEvent):
def serialize(self):
return {'data': time.time()}

with franz.RabbitProducer(exchange='topic_link') as p:
while True:
key = random.choice(['', 'hello.bob'])
p.send_message(key, FranzData())

### Consuming messages
import franz

def callback(ch, method, properties, body):
print('[+] {} from {}'.format(body, method.routing_key))

with franz.RabbitConsumer('hello.*', exchange='topic_link') as c:

## Kafka
### Sending a message
import franz
from myapp.models import SomeModel # SomeModel must inherit `franz.FranzEvent`

instance = SomeModel.objects.get(pk=1)
producer = franz.KafkaProducer()
producer.send_message('TopicA', instance)

### Consuming messages
import franz

consumer = franz.KafkaConsumer('TopicA')
for message in consumer:

### Kafka/Docker Resources

- [Docker image](
- [Helpful article](
- Create topic
./ --create --topic test --replication-factor 1 --partitions 1 --zookeeper
- Consuming
./ --topic test --from-beginning --zookeeper
- Producing
./ --topic test --broker-list

# Testing
# setup versions
pyenv install 3.5.3
pyenv install 3.6.3
pyenv install 3.7.0
pyenv virtualenv franz 3.5.3
pyenv local franz 3.5.3 3.6.3 3.7.0
pip install -r requirements-dev.txt

# run tests (python 3.5, 3.6, 3.7)

Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
franz-0.0.11.tar.gz (6.5 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page