This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import sys | |
from kafka import KafkaProducer | |
from outboxexample import settings | |
import signal | |
producer = KafkaProducer(bootstrap_servers=[settings.KAFKA_HOST]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from kafka import KafkaConsumer | |
from outboxexample import settings | |
print("starting consumer", settings.KAFKA_HOST) | |
NOTES_TOPIC = "notes" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.7' | |
networks: | |
my_network: | |
services: | |
zookeeper: | |
image: confluentinc/cp-zookeeper:latest | |
hostname: zookeeper | |
environment: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir django-jaiminho-outbox-example | |
cd django-jaiminho-outbox-example | |
pip install django==4.2 | |
django-admin startproject outboxexample . | |
python manage.py startapp notes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
├── notes | |
│ ├── admin.py | |
│ ├── apps.py | |
│ ├── __init__.py | |
│ ├── kafka_producer.py | |
│ ├── migrations | |
│ │ ├── 0001_initial.py | |
│ │ ├── __init__.py | |
│ ├── models.py | |
│ ├── tests.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
touch requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker-compose up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
relayer: | |
build: . | |
command: python manage.py events_relay --run-in-loop | |
volumes: | |
- .:/app | |
env_file: | |
- .env | |
depends_on: | |
kafka: | |
condition: service_healthy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python manage.py migrate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from jaiminho.constants import PublishStrategyType | |
JAIMINHO_CONFIG = { | |
"PUBLISH_STRATEGY": PublishStrategyType.KEEP_ORDER, | |
} |