RabbitMQ

Detailed documentation on the RabbitMQ pubsub component

Setup RabbitMQ

You can run a RabbitMQ server locally using Docker:

  1. docker run -d --hostname my-rabbit --name some-rabbit rabbitmq:3

You can then interact with the server using the client port: localhost:5672.

The easiest way to install RabbitMQ on Kubernetes is by using the Helm chart:

  1. helm install rabbitmq stable/rabbitmq

Look at the chart output and get the username and password.

This will install RabbitMQ into the default namespace. To interact with RabbitMQ, find the service with: kubectl get svc rabbitmq.

For example, if installing using the example above, the RabbitMQ server client address would be:

rabbitmq.default.svc.cluster.local:5672

Create a Dapr component

The next step is to create a Dapr component for RabbitMQ.

Create the following YAML file named rabbitmq.yaml:

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: <NAME>
  5. namespace: <NAMESPACE>
  6. spec:
  7. type: pubsub.rabbitmq
  8. version: v1
  9. metadata:
  10. - name: host
  11. value: <REPLACE-WITH-HOST> # Required. Example: "amqp://rabbitmq.default.svc.cluster.local:5672", "amqp://localhost:5672"
  12. - name: durable
  13. value: <REPLACE-WITH-DURABLE> # Optional. Default: "false"
  14. - name: deletedWhenUnused
  15. value: <REPLACE-WITH-DELETE-WHEN-UNUSED> # Optional. Default: "false"
  16. - name: autoAck
  17. value: <REPLACE-WITH-AUTO-ACK> # Optional. Default: "false"
  18. - name: deliveryMode
  19. value: <REPLACE-WITH-DELIVERY-MODE> # Optional. Default: "0". Values between 0 - 2.
  20. - name: requeueInFailure
  21. value: <REPLACE-WITH-REQUEUE-IN-FAILURE> # Optional. Default: "false".

Warning

The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described here.

Apply the configuration

Visit this guide for instructions on configuring pub/sub components.

Related links

Last modified February 16, 2021: Merge pull request #1235 from dapr/update-v0.11 (b4e9fbb)