# switch

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [connect-full.txt](https://docs.redpanda.com/connect-full.txt)

---
title: switch
latest-connect-version: 4.93.0
latest-operator-version: v26.1.4
latest-console-tag: v3.7.3
latest-redpanda-tag: v26.1.9
docname: outputs/switch
page-component-name: connect
page-version: master
page-component-version: master
page-component-title: Connect
page-relative-src-path: outputs/switch.adoc
page-edit-url: https://github.com/redpanda-data/rp-connect-docs/edit/main/modules/components/pages/outputs/switch.adoc
page-git-created-date: "2024-05-24"
page-git-modified-date: "2026-05-26"
---

<!-- Source: https://docs.redpanda.com/connect/components/outputs/switch.md -->

**Type:** Output ▼

[Output](https://docs.redpanda.com/connect/components/outputs/switch/)[Processor](https://docs.redpanda.com/connect/components/processors/switch/)[Scanner](https://docs.redpanda.com/connect/components/scanners/switch/)

**Available in:** [Cloud](https://docs.redpanda.com/cloud-data-platform/develop/connect/components/outputs/switch/%20%22View%20the%20Cloud%20version%20of%20this%20component%22), Self-Managed

The switch output type allows you to route messages to different outputs based on their contents.

#### Common

```yml
outputs:
  label: ""
  switch:
    retry_until_success: false
    cases: [] # No default (required)
```

#### Advanced

```yml
outputs:
  label: ""
  switch:
    retry_until_success: false
    strict_mode: false
    cases: [] # No default (required)
```

Messages that do not pass the check of a single output case are effectively dropped. In order to prevent this outcome set the field [`strict_mode`](#strict_mode) to `true`, in which case messages that do not pass at least one case are considered failed and will be nacked and/or reprocessed depending on your input.

## [](#examples)Examples

### [](#basic-multiplexing)Basic Multiplexing

The most common use for a switch output is to multiplex messages across a range of output destinations. The following config checks the contents of the field `type` of messages and sends `foo` type messages to an `amqp_1` output, `bar` type messages to a `gcp_pubsub` output, and everything else to a `redis_streams` output.

Outputs can have their own processors associated with them, and in this example the `redis_streams` output has a processor that enforces the presence of a type field before sending it.

```yaml
output:
  switch:
    cases:
      - check: this.type == "foo"
        output:
          amqp_1:
            urls: [ amqps://guest:guest@localhost:5672/ ]
            target_address: queue:/the_foos

      - check: this.type == "bar"
        output:
          gcp_pubsub:
            project: dealing_with_mike
            topic: mikes_bars

      - output:
          redis_streams:
            url: tcp://localhost:6379
            stream: everything_else
          processors:
            - mapping: |
                root = this
                root.type = this.type | "unknown"
```

### [](#control-flow)Control Flow

The `continue` field allows messages that have passed a case to be tested against the next one also. This can be useful when combining non-mutually-exclusive case checks.

In the following example a message that passes both the check of the first case as well as the second will be routed to both.

```yaml
output:
  switch:
    cases:
      - check: 'this.user.interests.contains("walks").catch(false)'
        output:
          amqp_1:
            urls: [ amqps://guest:guest@localhost:5672/ ]
            target_address: queue:/people_what_think_good
        continue: true

      - check: 'this.user.dislikes.contains("videogames").catch(false)'
        output:
          gcp_pubsub:
            project: people
            topic: that_i_dont_want_to_hang_with
```

## [](#fields)Fields

### [](#cases)`cases[]`

A list of switch cases, outlining outputs that can be routed to.

**Type**: `object`

```yaml
# Examples:
cases:
  - check: this.urls.contains("http://benthos.dev")
    continue: true
    output:
      cache:
        key: ${!json("id")}
        target: foo
  - output:
      s3:
        bucket: bar
        path: ${!json("id")}
```

### [](#cases-check)`cases[].check`

A [Bloblang query](https://docs.redpanda.com/connect/guides/bloblang/about/) that should return a boolean value indicating whether a message should be routed to the case output. If left empty the case always passes.

**Type**: `string`

**Default**: `""`

```yaml
# Examples:
check: this.type == "foo"

# ---

check: this.contents.urls.contains("https://benthos.dev/")
```

### [](#cases-continue)`cases[].continue`

Indicates whether, if this case passes for a message, the next case should also be tested.

**Type**: `bool`

**Default**: `false`

### [](#cases-output)`cases[].output`

An [output](https://docs.redpanda.com/connect/components/outputs/about/) for messages that pass the check to be routed to.

**Type**: `output`

### [](#retry_until_success)`retry_until_success`

If a selected output fails to send a message this field determines whether it is reattempted indefinitely. If set to false the error is instead propagated back to the input level.

If a message can be routed to >1 outputs it is usually best to set this to true in order to avoid duplicate messages being routed to an output.

**Type**: `bool`

**Default**: `false`

### [](#strict_mode)`strict_mode`

This field determines whether an error should be reported if no condition is met. If set to true, an error is propagated back to the input level. The default behavior is false, which will drop the message.

**Type**: `bool`

**Default**: `false`