Creating a RabbitMQSource

This topic describes how to create a RabbitMQSource.

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. A working RabbitMQ Instance, we recommend to create one Using the RabbitMQ Cluster Operator. For more information about configuring the RabbitmqCluster CRD, see the RabbitMQ website

Install the RabbitMQ controller

  1. Install the RabbitMQSource controller by running the command:

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

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

    Example output:

    1. NAME READY UP-TO-DATE AVAILABLE AGE
    2. rabbitmq-controller-manager 1/1 1 1 3s
    3. rabbitmq-webhook 1/1 1 1 4s

Create a Service

  1. Create the event-display Service as a YAML file:

    1. apiVersion: serving.knative.dev/v1
    2. kind: Service
    3. metadata:
    4. name: event-display
    5. namespace: default
    6. spec:
    7. template:
    8. spec:
    9. containers:
    10. - # This corresponds to
    11. # https://github.com/knative/eventing/tree/main/cmd/event_display/main.go
    12. image: gcr.io/knative-releases/knative.dev/eventing/cmd/event_display
  2. Apply the YAML file by running the command:

    1. kubectl apply -f <filename>.yaml

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

    Example output:

    1. service.serving.knative.dev/event-display created
  3. Ensure that the Service Pod is running, by running the command:

    1. kubectl get pods

    The Pod name is prefixed with event-display:

    1. NAME READY STATUS RESTARTS AGE
    2. event-display-00001-deployment-5d5df6c7-gv2j4 2/2 Running 0 72s

Create a RabbitMQSource object

  1. Create a YAML file using the following template:

    1. apiVersion: sources.knative.dev/v1alpha1
    2. kind: RabbitmqSource
    3. metadata:
    4. name: <source-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. rabbitmqResourcesConfig:
    13. parallelism: 10
    14. exchangeName: "eventing-rabbitmq-source"
    15. queueName: "eventing-rabbitmq-source"
    16. delivery:
    17. retry: 5
    18. backoffPolicy: "linear"
    19. backoffDelay: "PT1S"
    20. sink:
    21. ref:
    22. apiVersion: serving.knative.dev/v1
    23. kind: Service
    24. name: event-display

    Where:

    • <source-name> is the name you want for your RabbitMQSource object.
    • <cluster-name> 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 Source, and connectionSecret is for an external RabbitMQ server.

  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.

Verify

Check the event-display Service to see if it is receiving events. It might take a while for the Source to start sending events to the Sink.

  1. kubectl -l='serving.knative.dev/service=event-display' logs -c user-container
  2. ☁️ cloudevents.Event
  3. Context Attributes,
  4. specversion: 1.0
  5. type: dev.knative.rabbitmq.event
  6. source: /apis/v1/namespaces/default/rabbitmqsources/<source-name>
  7. subject: f147099d-c64d-41f7-b8eb-a2e53b228349
  8. id: f147099d-c64d-41f7-b8eb-a2e53b228349
  9. time: 2021-12-16T20:11:39.052276498Z
  10. datacontenttype: application/json
  11. Data,
  12. {
  13. ...
  14. Random Data
  15. ...
  16. }

Cleanup

  1. Delete the RabbitMQSource:

    1. kubectl delete -f <source-yaml-filename>
  2. Delete the RabbitMQ credentials secret:

    1. kubectl delete -f <secret-yaml-filename>
  3. Delete the event display Service:

    1. kubectl delete -f <service-yaml-filename>

Additional information