> ## Documentation Index
> Fetch the complete documentation index at: https://sequinstream.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# How to stream Postgres to RabbitMQ

> Create message queues from Postgres events with RabbitMQ. Stream database changes to RabbitMQ to trigger workflows, keep services in sync, and more.

This guide shows you how to set up Postgres change data capture (CDC) and stream changes to RabbitMQ using Sequin.

With Postgres data streaming to RabbitMQ, you can trigger workflows, keep services in sync, [build audit logs](/how-to/create-audit-logs), [maintain caches](/how-to/maintain-caches), and more.

By the end of this how-to, you'll have database changes flowing to a RabbitMQ exchange.

<Tip>
  This is the how-to guide for streaming Postgres to RabbitMQ. See the [quickstart](/quickstart/rabbitmq) for a step-by-step walkthrough or the [reference](/reference/sinks/rabbitmq) for details on all configuration options.
</Tip>

## Prerequisites

If you're self-hosting Sequin, you'll need:

1. [Sequin installed](/running-sequin)
2. [A database connected](/connect-postgres)
3. A RabbitMQ server ready to go

## Basic setup

### Prepare RabbitMQ

You'll need a RabbitMQ server and exchange ready for Sequin to stream changes to. You can use either a local server for development or a cloud-hosted RabbitMQ service in production.

#### Local development with Docker

For local development, you can quickly spin up RabbitMQ using Docker:

```bash theme={null}
docker run -d --name rabbitmq \
  -p 5672:5672 \
  -p 15672:15672 \
  rabbitmq:3-management
```

This starts RabbitMQ with the management plugin enabled at [http://localhost:15672](http://localhost:15672) (login with guest/guest).

#### Configure RabbitMQ

Before creating your sink, set up RabbitMQ to receive messages:

1. Create an exchange:
   * Name: Choose a name for your exchange (e.g., "sequin")
   * Type: topic

2. Create a queue:
   * Name: Choose a name for your queue (e.g., "my-table-changes")

3. Create a binding:

   * From exchange: The exchange you created
   * To queue: The queue you created
   * Routing key: `sequin.changes.<database>.<schema>.<table>.*`

   This routing key pattern will match all changes to your table. The format is:
   `sequin.changes.<database>.<schema>.<table>.<action>`

## Create RabbitMQ sink

Navigate to the "Sinks" tab, click "Create Sink", and select "RabbitMQ Sink".

### Configure the source

<Steps>
  <Step title="Select source tables">
    Under "Source", select the schemas and tables you want to stream data from.
  </Step>

  <Step title="Add filters (optional)">
    Add [filters](/reference/filters) to the sink to control which database changes are sent to your RabbitMQ queue.
  </Step>

  <Step title="Add transform (optional)">
    Add a [transform](/reference/transforms) to the sink to modify the payload before it's sent to RabbitMQ.
  </Step>

  <Step title="Specify backfill">
    You can optionally indicate if you want to [backfill](reference/backfills) all or a portion of the table's existing data into RabbitMQ. Backfills are useful if you want to use RabbitMQ to process historical data.

    You can backfill at any time. If you don't want to backfill, toggle "Backfill" off.
  </Step>
</Steps>

### Configure RabbitMQ

<Steps>
  <Step title="Enter RabbitMQ connection details">
    Fill in your RabbitMQ connection details:

    * **Host** (required): The hostname of your RabbitMQ server
    * **Port** (required): The port number (default: 5672)
    * **Exchange** (required): The name of the exchange where messages will be published (max 255 characters)
    * **Virtual Host**: The RabbitMQ virtual host to use (default: "/", max 255 characters)
    * **Username**: The username for authentication
    * **Password**: The password for authentication
    * **TLS**: Enable TLS/SSL for secure connections
  </Step>

  <Step title="Create the sink">
    Give your sink a name, then click "Create RabbitMQ Sink".
  </Step>
</Steps>

## Verify & debug

To verify that your RabbitMQ sink is working:

1. Make some changes in your source table
2. Verify that the count of messages for your sink increases in the Sequin web console
3. Using the RabbitMQ management UI or CLI, check your queue:
   ```bash theme={null}
   rabbitmqadmin get queue=your-queue count=5
   ```
   You should see the messages from Sequin appear in the queue.

If messages don't seem to be flowing:

1. Click the "Messages" tab to view the state of messages for your sink
2. Click any failed message
3. Check the delivery logs for error details, including any RabbitMQ connection errors

## Next steps

* **Setup a consumer**

  Now that your Postgres data is flowing into RabbitMQ, you can setup a consumer to read from the queue and process the data.

  Refer to the [RabbitMQ sink reference](/reference/sinks/rabbitmq) for the shape of messages that Sequin will publish.

* **Deploy your implementation**

  When you're ready to deploy your implementation, see "[How to deploy to production](/how-to/deploy-to-production)".

* **Advanced configuration**

  For more about how RabbitMQ sinks work, see the [RabbitMQ sink reference](/reference/sinks/rabbitmq).
