Skip to content

Run Danube with docker-compose and MINIO as persistence storage

This guide provides instructions on how to run Danube Messaging using Docker and Docker Compose. It sets up ETCD for metadata storage and MinIO for topic persistence storage.

The MINIO storage is used as an example but can be used with any implemented storage layers.

The Danube supports two dispatch strategies:

  • Non-reliable dispatch: This strategy prioritizes speed and minimal resource usage by delivering messages directly from producers to subscribers without storing them. Messages flow through the broker in a "fire and forget" manner, achieving the lowest possible latency.
  • Reliable dispatch: This strategy prioritizes message delivery and reliability, by implementing a store-and-forward mechanism.

This guide focus on running Danube with a reliable dispatch strategy and MINIO as persistence storage.

Prerequisites

Ensure you have the following installed on your system:

  • Docker
  • Docker Compose (version v2.32.0 or higher)
  • The files mentioned below docker-compose.yml and danube_broker.yml are in this repository.

Docker Compose Configuration

Danube docker Compose

The docker-compose.yml file defines the following services:

  • ETCD (etcd): Stores Danube's cluster metadata.
  • Danube Brokers (broker1, broker2): Handles message routing. As the prerequisites, the etcd service must be healthy. Ensure that your danube_broker.yml configuration file is properly configured.
  • MinIO (minio): Provides object storage to persist messages.
  • Danube MinIO Storage (danube-minio-storage): Bridges Danube and MinIO. Implements the storage grpc service for Danube and connects to MinIO.

Setup

There are 2 alternatives to run the docker compose file:

  1. Clone the danube-storage repository and run the docker compose file from the test_minio_storage folder.
  2. Copy the docker-compose.yml and danube_broker.yml files to your local folder and run the docker compose file from that folder.

If you go with the second option, you have to modify the danube-minio-storage section from docker-compose.yml file to use the image from Container Registry instead of the Dockerfile build.

  danube-minio-storage:
    image: ghcr.io/danube-messaging/danube-storage:latest
    container_name: danube-minio-storage
    environment:
      STORAGE_TYPE: minio
      GRPC_PORT: 50060
      MINIO_ENDPOINT: minio:9000
      MINIO_ACCESS_KEY_ID: minioadmin
      MINIO_SECRET_ACCESS_KEY: minioadmin
      MINIO_BUCKET_NAME: danube-messages
      MINIO_LOCATION: us-east-1
    depends_on:
      minio:
        condition: service_healthy
    ports:
      - "50060:50060"

Running Danube Messaging

  1. Start the services using Docker Compose:

    docker-compose up --build
    
     danube-minio-storage                Built  
     Network test_minio_storage_default  Created 
     Container etcd-danube               Created 
     Container minio                     Created 
     Container broker2                   Created 
     Container broker1                   Created  
     Container danube-minio-storage      Created 
    

    or just docker-compose up if you use the danube-storage image.

    This command will download the necessary images and start the containers. Docker Compose will ensure that ETCD and MinIO are healthy before starting the Danube brokers and storage component.

  2. Verify running containers:

    docker ps
    

    This command will show you the running containers and their status.

    $ docker ps
    CONTAINER ID   IMAGE                                           COMMAND                  CREATED          STATUS                    PORTS                                                                                                                                           NAMES
    d791e51e7a29   test_minio_storage-danube-minio-storage         "./danube-minio-stor…"   35 seconds ago   Up 4 seconds              50051/tcp, 0.0.0.0:50060->50060/tcp, :::50060->50060/tcp                                                                                       danube-minio-storage
    
    ef4fe0528a57   ghcr.io/danube-messaging/danube-broker:latest   "/usr/local/bin/danu…"   35 seconds ago   Up 32 seconds             0.0.0.0:3000->3000/tcp, :::3000->3000/tcp, 0.0.0.0:6650->6650/tcp, :::6650->6650/tcp, 0.0.0.0:50051->50051/tcp, :::50051->50051/tcp, 6651/tcp   broker1
    
    ca1a41d1ef62   ghcr.io/danube-messaging/danube-broker:latest   "/usr/local/bin/danu…"   35 seconds ago   Up 32 seconds             0.0.0.0:3001->3001/tcp, :::3001->3001/tcp, 0.0.0.0:6651->6651/tcp, :::6651->6651/tcp, 0.0.0.0:50052->50052/tcp, :::50052->50052/tcp, 6650/tcp   broker2
    
    8a8c4a2e2d03   minio/minio                                     "/usr/bin/docker-ent…"   35 seconds ago   Up 34 seconds (healthy)   0.0.0.0:9000-9001->9000-9001/tcp, :::9000-9001->9000-9001/tcp                                                                                   minio
    
    b7cc1c6a2a03   quay.io/coreos/etcd:latest                      "/usr/local/bin/etcd"    35 seconds ago   Up 34 seconds (healthy)   0.0.0.0:2379-2380->2379-2380/tcp, :::2379-2380->2379-2380/tcp  
    
  3. Produce messages:

    Download the Danube CLI.

    Create a 100KB blob file, in order to fill faster the 5 MB segment size.

    yes 'Danube messaging platform is awesome!' | head -c 100K > test.blob
    

    Produce messages, (creates also a topic with reliable dispatch, meaning that the messages are stored and then delivered to the consumers).

    danube-cli produce -s http://localhost:6650 -m "none" -f ./test.blob -c 1000 --reliable  --segment-size 5  --retention expire --retention-period 7200
    
  4. Consume messages:

    Consume messages from the topic, creating an exclusive subscription.

    danube-cli consume -s http://localhost:6650 -m my_exclusive --sub-type exclusive
    

    The output should look like this:

    Received reliable message: [binary data] 
    Segment: 2, Offset: 41, Size: 102400 bytes, Total received: 9728000 bytes
    Producer: 9791760036514492028, Topic: /default/test_topic
    
    Received reliable message: [binary data] 
    Segment: 2, Offset: 42, Size: 102400 bytes, Total received: 9830400 bytes
    Producer: 9791760036514492028, Topic: /default/test_topic
    
    Received reliable message: [binary data] 
    Segment: 2, Offset: 43, Size: 102400 bytes, Total received: 9932800 bytes
    Producer: 9791760036514492028, Topic: /default/test_topic
    

Checking Stored Messages

Open the MinIO console in your browser: http://localhost:9001/buckets. Log in with minioadmin as both the username and password. You can see the buckets and objects created by Danube.

Stopping Danube Messaging

To stop and remove the containers:

$ docker-compose down

[+] Running 6/6
  Container danube-minio-storage      Removed         
  Container broker1                   Removed                  
  Container broker2                   Removed    
  Container minio                     Removed                                    
  Container etcd-danube               Removed  
  Network test_minio_storage_default  Removed