Quick RabbitMQ Refresher – DEV Community
December 24, 2024

Quick RabbitMQ Refresher – DEV Community

Publish the message to the exchange. Publishers just need to interact with them to deliver the message.

Message is sent to queue. Subscribers only need to interact with them to consume messages.

RabbitMQ binding Exchange to queue to decouple receivers and consumers.

You have great flexibility in routing messages from switches to queues. The most direct thing is direct Route (route based on a given routing key), which can act as unicast or multicast:

Another useful one is fan (without routing keys), this is pretty much a broadcast:

connect:

  • It is based on TCP and assumes long-term connections for efficiency (each protocol operation does not open a new connection).
  • By default, RabbitMQ will listen on port 5672 on all available interfaces.

path:

  • Lightweight connections that share a single TCP connection (multiplexed).
  • Channels exist only within wires, not individually.
  • It is common for each thread to open a new channel rather than sharing the channel between them.
  • Channels may be closed due to protocol exceptions.

A virtual host is roughly like a namespace:

  • Has a name.
  • Provides logical grouping and separation of resources.
  • Create and delete using rabbitmqctl or the HTTP API (no need to edit the configuration file).
  • Resource permissions in RabbitMQ are scoped per virtual host.

Counterintuitively, AMQP 1.0 is very different from 0.9.1, with nothing shared at the wire level. Many of RabbitMQ’s core ideas, such as exchange and routing keys, only exist in 0.9.1.

RabbitMQ is written in Erlang, which is perfectly suited to the problem it solves. Erlang applications are built from very lightweight (Erlang) processes that can be thought of as “living” objects, with data encapsulation and message passing, but the ability to change behavior at runtime.

Minisia It is a decentralized soft real-time database management system included in the Erlang standard library (Open Telecommunications Platform, OTP). It provides features such as atomic transactions, table replication, and flexible modes, making it ideal for use cases that require high availability and fault tolerance.

capri It is a new storage backend for RabbitMQ metadata, designed to replace Mnesia. It is built on the Raft protocol and simplifies cluster management by automatically handling network partitions (similar to quorum queues) without additional configuration.

Mnesia is the original store for RabbitMQ, and despite the introduction of Khepri, is still the default store as of this writing.

Rabbit provides a lovely web interface that runs by default, allowing it to be run directly on a web browser:

  • Message published.
  • Message consumption.
  • Monitor usage.
  • Basic server statistics.

If you are running locally you can access http://localhost:15672 and use guest as username and password.

  • Users have configuration, write and read permissions.
  • Configuration: Create, destroy or change resources (switches and queues).
  • Write: message release.
  • Read: Message consumption.
  • Permission is a regular expression, “^foo” grants permission to resources whose names begin with “foo”.
  • Permissions are per virtual host.
  • sudo service rabbitmq-server status
  • sudo rabbitmq-plugins enable rabbitmq-management
  • sudo service rabbitmq-server restart
  • sudo rabbitmqctl add_user ccm-admin hare123
  • sudo rabbitmqctl set_user_tags ccm-admin administrator
  • sudo rabbitmqctl add_vhost ccm_dev_vhost
  • sudo rabbitmqctl set_permissions -p ccm-dev-host ccm-admin ".*" ".*" ".*"

2024-12-24 02:12:28

Leave a Reply

Your email address will not be published. Required fields are marked *