Command Line Interface (CLI)
django-streaming
provides a command-line interface (CLI) built with click
to help you interact with the streaming system, especially for testing and debugging.
Basic Usage
To see the available commands, run:
This will show you the main commands: listen
, send
, purge
, and check
.
configure
The configure
command allows you to configure exchanges and queues on the RabbitMQ broker.
Options:
--queues / --no-queues
: (flag) Whether to configure queues.--debug
: (flag) Enable debug logging.
Example:
This command will configure the exchanges and all queues defined in STREAMING['QUEUES']
.
listen
The listen
command allows you to listen for messages from one or more RabbitMQ queues configured in your settings.py
.
Options:
-q
,--queues TEXT
: The alias of the queue to listen to. You can specify this option multiple times to listen to multiple queues. If not provided, it will listen to all queues defined inSTREAMING['QUEUES']
.--payload
: (flag) Print the message payload.--reload
: (flag) Enable auto-reloading for development.--pretty
: (flag) Pretty-print the JSON payload.
Example:
This command will listen to the queue with the alias invoices
and pretty-print the payload.
send
The send
command sends a message to a RabbitMQ exchange with a specific routing key.
Arguments:
ROUTING_KEY
: (required) The routing key for the message.
Options:
--message TEXT
: The message to send. Can be a plain string or a JSON string. Defaults to "Test Message".
Example:
purge
The purge
command purges all messages from all queues configured in STREAMING['QUEUES']
.
Example:
check
The check
command displays the current django-streaming
configuration and checks the connection to the message broker.