RabbitMQ message broker

Learn how to use a RabbitMQ resource in your application

Overview

The rabbitmq.com/MessageQueue resource offers a RabbitMQ message broker.

Resource format


resource rabbitmq 'Applications.Messaging/rabbitmqQueues@2023-10-01-preview' = {
  name: 'rabbitmq'
  properties: {
    environment: environment
    application: app.id
    recipe: {
      // Name a specific Recipe to use
      name: 'rabbit'
      // Optionally set recipe parameters if needed (specific to the Recipe)
      parameters: {
        queue: '*****'
      }
    }
  }
}

param rmqUsername string
@secure()
param rmqPassword string
param rmqHost string
param rmqPort int
param vHost string

resource rabbitmq 'Applications.Messaging/rabbitmqQueues@2023-10-01-preview' = {
  name: 'rabbitmq'
  properties: {
    environment: environment
    application: app.id
    resourceProvisioning: 'manual'
    queue: 'radius-queue'
    host: rmqHost
    port: rmqPort
    vHost: vHost
    username: rmqUsername
    secrets: {
      password: rmqPassword
    }
  }
}

Top-level

KeyRequiredDescriptionExample
nameyThe name of your resource.mongo
locationyThe location of your resource. See common values for more information.global
propertiesyProperties of the resource.See below

Properties

KeyRequiredDescriptionExample
applicationnThe ID of the application resource this resource belongs to.app.id
environmentyThe ID of the environment resource this resource belongs to.env.id
resourceProvisioningnSpecifies how the underlying service/resource is provisioned and managed. Options are to provision automatically via ‘recipe’ or provision manually via ‘manual’. Selection determines which set of fields to additionally require. Defaults to ‘recipe’.manual
hostnThe hostname of the RabbitMQ instance.rabbitmq.hello.com
portnThe port of the RabbitMQ instance. Defaults to 5672.5672
vHostnThe RabbitMQ virtual host (vHost) the client will connect to. Defaults to no vHost.vHost
tlsnSpecifies whether to use SSL when connecting to the RabbitMQ instance.tls
usernamenUsername to use when connecting to the target rabbitMQ.'myusername'
recipenConfiguration for the Recipe which will deploy the backing infrastructure.See below
resourcesnAn array of IDs of the underlying resources.See below
queueyThe name of the queue.'orders'
secretsyConfiguration used to manually specify a RabbitMQ container or other service providing a RabbitMQ Queue.See secrets below.

Recipe

PropertyRequiredDescriptionExample(s)
namenSpecifies the name of the Recipe that should be deployed. If not set, the name defaults to default.name: 'azure-prod'
parametersnAn object that contains a list of parameters to set on the Recipe.{ port: '10040' }

Resources

PropertyRequiredDescriptionExample(s)
idnResource ID of the supporting resource.queue.id

Secrets

Secrets are used when defining a RabbitMQ resource with a container or external service.

PropertyDescriptionExample
uriThe URI to the Rabbit MQ Message Queue. Write only'amqp://${username}:${password}@${rmqContainer.properties.hostname}:${rmqContainer.properties.port}'
passwordThe password used to connect to this RabbitMQ. Write only.'mypassword'

Methods

PropertyDescriptionExample
listSecrets()Get the secrets for the RabbitMQ.listSecrets().uri

Resource provisioning

Provision with a Recipe

Recipes automate infrastructure provisioning using approved templates. When no Recipe configuration is set Radius will use the Recipe registered as the default in the environment for the given resource. Otherwise, a Recipe name and parameters can optionally be set.

Provision manually

If you want to manually manage your infrastructure provisioning outside of Recipes, you can set resourceProvisioning to 'manual' and provide all necessary parameters and values and values that enable Radius to deploy or connect to the desired infrastructure.

Environment variables for connections

Other Radius resources, such as containers, may connect to a RabbitMQ resource via connections. When a connection to RabbitMQ named, for example, myconnection is declared, Radius injects values into environment variables that are then used to access the connected RabbitMQ resource:

Environment variableExample(s)
CONNECTION_MYCONNECTION_QUEUE'orders'
CONNECTION_MYCONNECTION_HOST'rabbitmq.svc.local.cluster'
CONNECTION_MYCONNECTION_PORT'5672'
CONNECTION_MYCONNECTION_VHOST'qa1'
CONNECTION_MYCONNECTION_USERNAME'guest'
CONNECTION_MYCONNECTION_TLS'true'
CONNECTION_MYCONNECTION_URI'amqp://${username}:${password}@${rmqContainer.properties.hostname}:${rmqContainer.properties.port}'
CONNECTION_MYCONNECTION_PASSWORD'password'