AMQP

RabbitMQ

Concepts: RabbitMQ Connection vs Channel

RabbitMQ for Beginners - Exchanges, Routing Keys, Bindings

Configuration and authentication

Create users and virtual hosts:

RMQ_USERNAME=rmq_user
RMQ_PASSWORD=s3cr3tp4ssw0rd
RMQ_VHOST=rmq_vhost
rabbitmqctl add_user $RMQ_USERNAME $RMQ_PASSWORD
rabbitmqctl add_vhost $RMQ_VHOST
rabbitmqctl set_permissions -p $RMQ_VHOST $RMQ_USERNAME ".*" ".*" ".*"

This is not persistent, will only live for the lifetime of the container. (todo: find documentation about this?)

Using the official docker image (RabbitMQ on Docker Hub), we can use an undocumented feature: the entrypoint will read /etc/rabbitmq/definitions.json if it exists and use it to define entities in rabbitmq, so if we derive our image from that adding this file, it will auto add them.

Definitions file (/etc/rabbitmq/definitions.json):

{       
    "users":[
            {"name":"rmq_user","password_hash":"...","tags":""},
            {"name":"rmq_admin","password_hash":"...","tags":"administrator"}
    ],
    "vhosts":[
            {"name":"/"}
    ],
    "permissions":[
            ...
    ],
    "parameters":[],
    "policies":[
            ...
    ],
    "queues":[
            ...
    ],
    "exchanges":[
            ...
    ],
    "bindings":[
            ...
    ]
}

Generate a definitions file from a running broker

To dump the current configuration into a definitions.json, use the rabbitmqadmin script, which talks to the RabbitMQ management plugin. The official Docker image ships the plugin when the management tag is used.

Reach the management UI through a port-forward:

kubectl port-forward rabbitmq-54644f7685-gf8hw 15672:15672

Then open http://localhost:15672/ (default login guest:guest).

Clients

Topology

Exchange to exchange bindings