Skip to main content
RabbitMQ is a message broker that supports multiple messaging protocols, such as the Advanced Message Queuing Protocol (AMQP). It gives your apps a common platform to send and receive messages and your messages a safe place to live until they’re received.

Supported versions

You can select the major and minor version. Patch versions are applied periodically for bug fixes and the like. When you deploy your app, you always get the latest available patches.

Relationship reference

For each service defined via a relationship to your application, Upsun automatically generates corresponding environment variables within your application container, in the $<RELATIONSHIP-NAME>_<SERVICE-PROPERTY> format. Here is example information available through the service environment variables themselves, or through the PLATFORM_RELATIONSHIPS environment variable.
You can obtain the complete list of available service environment variables in your app container by running upsun ssh env.Note that the information about the relationship can change when an app is redeployed or restarted or the relationship is changed. So your apps should only rely on the service environment variables directly rather than hard coding any values.

Usage example

1. Configure the service

To define the service, use the rabbitmq type: Note that changing the name of the service replaces it with a brand new service and all existing data is lost. Back up your data before changing the service.

2. Define the relationship

To define the relationship, use the following configuration:
You can define SERVICE_NAME as you like, so long as it’s unique between all defined services and matches in both the application and services configuration.The example above leverages default endpoint configuration for relationships. That is, it uses default endpoints behind the scenes, providing a relationship (the network address a service is accessible from) that is identical to the name of that service.Depending on your needs, instead of default endpoint configuration, you can use explicit endpoint configuration.With the above definition, the application container (APP_NAME) now has access to the service via the relationship SERVICE_NAME and its corresponding service environment variables.

Example configuration

Use in app

To use the configured service in your app, add a configuration file similar to the following to your project. This configuration defines a single application (myapp), whose source code exists in the <PROJECT_ROOT>/myapp directory.
myapp has access to the rabbitmq service, via a relationship whose name is identical to the service name (as per default endpoint configuration for relationships).
From this, myapp can retrieve access credentials to the service through the relationship environment variables.
myapp/.environment
# Set environment variables for individual credentials.
# For more information, please visit https://docs.upsun.com/development/variables.html#service-environment-variables.
export QUEUE_SCHEME="${RABBITMQ_SCHEME}"
export QUEUE_USERNAME="${RABBITMQ_USERNAME}"
export QUEUE_PASSWORD="${RABBITMQ_PASSWORD}"
export QUEUE_HOST="${RABBITMQ_HOST}"
export QUEUE_PORT="${RABBITMQ_PORT}"

# Set a single RabbitMQ connection string variable for AMQP.
export AMQP_URL="${QUEUE_SCHEME}://${QUEUE_USERNAME}:${QUEUE_PASSWORD}@${QUEUE_HOST}:${QUEUE_PORT}/"
The above file — .environment in the myapp directory — is automatically sourced by Upsun into the runtime environment, so that the variable AMQP_URL can be used within the application to connect to the service. Note that AMQP_URL, and all Upsun service environment variables like RABBITMQ_HOST, are environment-dependent. Unlike the build produced for a given commit, they can’t be reused across environments and only allow your app to connect to a single service instance on a single environment. A file very similar to this is generated automatically for your when using the upsun ify command to migrate a codebase to Upsun.

Connect to RabbitMQ

When debugging, you may want to connect directly to your RabbitMQ service. You can connect in multiple ways: In each case, you need the login credentials that you can obtain from the relationship.

Via SSH

To connect directly to your RabbitMQ service in an environment, open an SSH tunnel with the Upsun CLI. To open an SSH tunnel to your service with port forwarding, run the following command:
upsun tunnel:single --gateway-ports
Then configure a RabbitMQ client to connect to this tunnel using the credentials from the relationship. See a list of RabbitMQ client libraries.

Access the management UI

RabbitMQ offers a management plugin with a browser-based UI. You can access this UI with an SSH tunnel. To open a tunnel, follow these steps.
  1. SSH into your app container with a flag for local port forwarding:
  2. ssh $(upsun ssh --pipe) -L 15672:<VariableBlock name="RELATIONSHIP_NAME" />.internal:15672
    
    is the name you defined.
  3. Open http://localhost:15672 in your browser. Log in using the username and password from the relationship.

Configuration options

You can configure your RabbitMQ service in the services configuration with the following options:
NameTypeRequiredDescription
vhostsList of stringsNoVirtual hosts used for logically grouping resources.
You can configure additional virtual hosts, which can be useful for separating resources, such as exchanges, queues, and bindings, into their own namespaces. To create virtual hosts, add them to your configuration as in the following example:

Upgrading

When upgrading RabbitMQ, skipping major versions (e.g. 3.7 -> 3.11) is not supported. Make sure you upgrade sequentially (3.7 -> 3.8 -> 3.9 -> 3.10 -> 3.11) and that each upgrade commit translates into an actual deployment.

Exporting Data

RabbitMQ stores durable queues, exchanges, bindings, users, virtual hosts, and policies on disk. You can export the full definitions (schema + messages metadata) using the RabbitMQ management API.
  1. Open an SSH tunnel:
Terminal
upsun tunnel:single --relationship <RELATIONSHIP_NAME>
  1. Export definitions (topology: exchanges, queues, bindings, policies):
Terminal
curl -u guest:<RABBITMQ_PASSWORD> \
  http://127.0.0.1:15672/api/definitions \
  -o rabbitmq-definitions.json
The management API is available on port 15672. The default username is guest. Retrieve the password from the service environment variables:
Terminal
upsun ssh -- env | grep RABBITMQ_PASSWORD
  1. To export messages from a specific queue:
Terminal
curl -u guest:<RABBITMQ_PASSWORD> \
  -X POST http://127.0.0.1:15672/api/queues/%2F/<QUEUE_NAME>/get \
  -H "Content-Type: application/json" \
  -d '{"count": 10000, "ackmode": "ack_requeue_true", "encoding": "auto"}' \
  -o rabbitmq-messages.json
The definitions.json file can later be imported into any RabbitMQ instance via:
Terminal
curl -u guest:<PASSWORD> \
  -X POST http://<HOST>:15672/api/definitions \
  -H "Content-Type: application/json" \
  -d @rabbitmq-definitions.json
Last modified on March 11, 2026