Creating a RabbitMQ Broker

This topic describes how to create a RabbitMQ Broker.

Prerequisites

  1. You have installed Knative Eventing.
  2. You have installed CertManager v1.5.4 - easiest integration with RabbitMQ Messaging Topology Operator
  3. You have installed RabbitMQ Messaging Topology Operator - our recommendation is latest release with CertManager
  4. You have access to a working RabbitMQ instance. You can create a RabbitMQ instance by using the RabbitMQ Cluster Kubernetes Operator. For more information see the RabbitMQ website.

Install the RabbitMQ controller

  1. Install the RabbitMQ controller by running the command:

    1. kubectl apply -f https://github.com/knative-sandbox/eventing-rabbitmq/releases/download/knative-v1.8.2/rabbitmq-broker.yaml
  2. Verify that rabbitmq-broker-controller and rabbitmq-broker-webhook are running:

    1. kubectl get deployments.apps -n knative-eventing

    Example output:

    1. NAME READY UP-TO-DATE AVAILABLE AGE
    2. eventing-controller 1/1 1 1 10s
    3. eventing-webhook 1/1 1 1 9s
    4. rabbitmq-broker-controller 1/1 1 1 3s
    5. rabbitmq-broker-webhook 1/1 1 1 4s

Create a RabbitMQBrokerConfig object

  1. Create a YAML file using the following template:

    1. apiVersion: eventing.knative.dev/v1alpha1
    2. kind: RabbitmqBrokerConfig
    3. metadata:
    4. name: <rabbitmq-broker-config-name>
    5. spec:
    6. rabbitmqClusterReference:
    7. # Configure name if a RabbitMQ Cluster Operator is being used.
    8. name: <cluster-name>
    9. # Configure connectionSecret if an external RabbitMQ cluster is being used.
    10. connectionSecret:
    11. name: rabbitmq-secret-credentials
    12. queueType: quorum

    Where:

    • is the name you want for your RabbitMQBrokerConfig object.
    • is the name of the RabbitMQ cluster you created earlier.

    Note

    You cannot set name and connectionSecret at the same time, since name is for a RabbitMQ Cluster Operator instance running in the same cluster as the Broker, and connectionSecret is for an external RabbitMQ server.

  2. Apply the YAML file by running the command:

    1. kubectl create -f <filename>

    Where <filename> is the name of the file you created in the previous step.

Create a RabbitMQBroker object

  1. Create a YAML file using the following template:

    1. apiVersion: eventing.knative.dev/v1
    2. kind: Broker
    3. metadata:
    4. annotations:
    5. eventing.knative.dev/broker.class: RabbitMQBroker
    6. name: <broker-name>
    7. spec:
    8. config:
    9. apiVersion: rabbitmq.com/v1beta1
    10. kind: RabbitmqBrokerConfig
    11. name: <rabbitmq-broker-config-name>

    Where <rabbitmq-broker-config-name> is the name you gave your RabbitMQBrokerConfig in the step above.

  2. Apply the YAML file by running the command:

    1. kubectl apply -f <filename>

    Where <filename> is the name of the file you created in the previous step.

Configure message ordering

By default, Triggers will consume messages one at a time to preserve ordering. If ordering of events isn’t important and higher performance is desired, you can configure this by using the parallelism annotation. Setting parallelism to n creates n workers for the Trigger that will all consume messages in parallel.

The following YAML shows an example of a Trigger with parallelism set to 10:

  1. apiVersion: eventing.knative.dev/v1
  2. kind: Trigger
  3. metadata:
  4. name: high-throughput-trigger
  5. annotations:
  6. rabbitmq.eventing.knative.dev/parallelism: "10"
  7. ...

Additional information