AMQP Bridge Extension Swiftlet
Overview
The AMQP Bridge Extension Swiftlet enables message bridging between AMQP 1.0 and AMQP 0.9.1 brokers, allowing SwiftMQ routers to interconnect with external AMQP brokers or to bridge messages between different AMQP protocol versions. It supports the configuration and management of multiple bridges, each of which defines a source and target connection, facilitating bidirectional or unidirectional message flows between AMQP endpoints.
Features
AMQP 1.0 and 0.9.1 Bridge Management
This Swiftlet supports the creation and management of bridges for both AMQP 1.0 and AMQP 0.9.1 protocols. Each bridge is defined as an entity under either the bridges100 (for AMQP 1.0) or bridges091 (for AMQP 0.9.1) entity lists. A bridge consists of a source and a target connection definition, specifying how messages are consumed from one AMQP broker and published to another. The bridge can be enabled or disabled dynamically, and supports automatic reconnection with a configurable retry interval.
For AMQP 1.0, the bridge supports configurable transfer Quality of Service (at-most-once, at-least-once, exactly-once) and leverages connection templates for advanced connection tuning. For AMQP 0.9.1, the bridge supports detailed queue and exchange configuration, including durability, exclusivity, and auto-delete options.
Bridge lifecycle is managed by the Swiftlet, including connection establishment, error handling, and reconnection logic. Usage statistics such as connect time, last transfer time, and number of messages transferred are tracked per bridge and exposed under the usage entity.
AMQP 1.0 Bridge Configuration
AMQP 1.0 bridges are defined under the bridges100 entity list. Each bridge specifies a source and target with connection parameters such as remote hostname, port, SSL usage, SASL authentication, and address. The bridge can be configured for transfer QoS and uses a connection template for fine-tuning protocol and buffer parameters. The bridge controller manages message flow using a poller and supports unsettled delivery tracking for exactly-once semantics.
AMQP 0.9.1 Bridge Configuration
AMQP 0.9.1 bridges are defined under the bridges091 entity list. Each bridge specifies a source and target with AMQP connection URIs, exchange and queue parameters, and routing keys. The bridge controller manages consumer and producer setup, including queue declaration and binding, and handles message transfer with acknowledgement and error recovery.
Bridge Usage Monitoring
For each active bridge, runtime usage statistics are maintained under the usage entity. These include the connection time, last message transfer time, and the total number of messages transferred. These statistics are updated automatically by the bridge controllers and provide operational insight into bridge activity.
Configuration Example:
<swiftlet name="xt$amqpbridge">
<connection-templates>
<connection-template name="fast">
<idle-timeout>60000</idle-timeout>
<max-frame-size>262144</max-frame-size>
</connection-template>
</connection-templates>
<bridges100>
<bridge100 name="bridge1" enabled="true">
<source remote-hostname="amqp1.example.com" remote-port="5672" sasl-enabled="true" sasl-anonymous-login="false" sasl-loginname="user" sasl-password="pass" source-address="queue1" connection-template="fast"/>
<target remote-hostname="amqp2.example.com" remote-port="5672" sasl-enabled="true" sasl-anonymous-login="false" sasl-loginname="user2" sasl-password="pass2" target-address="queue2" connection-template="fast"/>
</bridge100>
</bridges100>
<bridges091>
<bridge091 name="legacybridge" enabled="true">
<source connect-uri="amqp://user:pass@legacyhost:5672/" exchange-name="ex1" exchange-type="topic" queue-name="q1" routing-key="key1"/>
<target connect-uri="amqp://user:pass@targethost:5672/" exchange-name="ex2" routing-key="key2"/>
</bridge091>
</bridges091>
</swiftlet>
Connection Templates for AMQP 1.0
Connection templates allow administrators to define reusable sets of connection parameters for AMQP 1.0 endpoints. These templates specify protocol-level settings such as idle timeout, maximum frame size, buffer sizes, session window sizes, and link credit. Bridges reference these templates by name, enabling consistent and efficient configuration across multiple bridges. The default template is used unless overridden per connection.
Configuration Example:
<swiftlet name="xt$amqpbridge">
<connection-templates>
<connection-template name="highperf" idle-timeout="30000" max-frame-size="262144"/>
</connection-templates>
</swiftlet>
Job-Based Bridge Activation
The Swiftlet integrates with the SwiftMQ scheduler to provide job-based activation and deactivation of bridges. A job named Bridge can be scheduled or triggered to enable or disable a specific bridge by name and type (either 100 for AMQP 1.0 or 091 for AMQP 0.9.1). This allows for automated or time-based control of bridge connections, supporting operational requirements such as scheduled maintenance or load management.
Configuration Guide
Bridging Between Two AMQP 1.0 Brokers with Custom QoS
Use this scenario to transfer messages between two AMQP 1.0 brokers with exactly-once delivery semantics and custom connection parameters. This is useful when integrating SwiftMQ with other AMQP 1.0-compliant systems, ensuring reliable message transfer.
- Define a connection template with custom idle timeout and frame size.
- Create a bridge under
bridges100, referencing the template and specifying source and target connection details. - Enable the bridge to initiate message transfer.
<swiftlet name="xt$amqpbridge">
<connection-templates>
<connection-template name="custom" idle-timeout="90000" max-frame-size="262144"/>
</connection-templates>
<bridges100>
<bridge100 name="amqp1toamqp2" enabled="true" transfer-qos="exactly-once">
<source remote-hostname="broker1.example.com" remote-port="5672" sasl-enabled="true" sasl-anonymous-login="false" sasl-loginname="alice" sasl-password="secret" source-address="inputqueue" connection-template="custom"/>
<target remote-hostname="broker2.example.com" remote-port="5672" sasl-enabled="true" sasl-anonymous-login="false" sasl-loginname="bob" sasl-password="secret2" target-address="outputqueue" connection-template="custom"/>
</bridge100>
</bridges100>
</swiftlet>
Bridging from RabbitMQ (AMQP 0.9.1) to SwiftMQ
This scenario is used to bridge messages from a RabbitMQ broker (AMQP 0.9.1) to a SwiftMQ router or another AMQP broker. It is useful for migration, integration, or interoperability purposes.
- Create a bridge under
bridges091specifying the source connection URI, exchange, queue, and routing key. - Specify the target connection URI and exchange/routing key as needed.
- Enable the bridge to start transferring messages.
<swiftlet name="xt$amqpbridge">
<bridges091>
<bridge091 name="rabbit2swift" enabled="true">
<source connect-uri="amqp://guest:guest@rabbitmqhost:5672/" exchange-name="amq.topic" exchange-type="topic" queue-name="rabbitqueue" routing-key="swift.in"/>
<target connect-uri="amqp://admin:secret@swiftmqhost:5672/" exchange-name="swift.exchange" routing-key="swift.out"/>
</bridge091>
</bridges091>
</swiftlet>
Scheduler Jobs
Bridge
Description: Activates a Bridge
Configuration Reference
The top-level entity in routerconfig.xml is <swiftlet name="xt$amqpbridge">.
<connection-templates> in <swiftlet name="xt$amqpbridge">
Templates for Connections
Each <connection-template> entry is identified by its name attribute (the Connection Template).
| Parameter | Type | Default | Mandatory | Reboot Required | Description |
|---|---|---|---|---|---|
idle-timeout |
Long | 120000 |
No | No | Idle Timeout (ms) |
max-frame-size |
Long | 131072 |
No | No | Maximum Frame Site (Bytes) |
container-id |
String | — | No | No | Container Id |
open-hostname |
String | — | No | No | Overwrites Hostname set in Open Frame |
input-buffer-size |
Integer | 1048576 |
No | No | Network Input Buffer Size (min: 1024) |
input-buffer-extend-size |
Integer | 1048576 |
No | No | Network Input Buffer Extend Size (min: 1024) |
output-buffer-size |
Integer | 131072 |
No | No | Network Output Buffer Size (min: 1024) |
output-buffer-extend-size |
Integer | 131072 |
No | No | Network Output Buffer Extend Size (min: 1024) |
session-incoming-window-size |
Integer | 100 |
No | No | Session Incoming Window Size (min: 1) |
session-outgoing-window-size |
Integer | 100 |
No | No | Session Outgoing Window Size (min: 1) |
source-link-credit |
Integer | 100 |
No | No | Source Link Credit (min: 1) |
<swiftlet name="xt$amqpbridge">
<connection-templates>
<connection-template name="..."/>
</connection-templates>
</swiftlet>
<bridges100> in <swiftlet name="xt$amqpbridge">
AMQP 1.0 Bridges
Each <bridge100> entry is identified by its name attribute (the AMQP 1.0 Bridge).
| Parameter | Type | Default | Mandatory | Reboot Required | Description |
|---|---|---|---|---|---|
enabled |
Boolean | false |
No | No | Enables/Disables this Connection |
retryinterval |
Long | 60000 |
No | No | Retry Interval (ms) for Re-Connect |
transfer-qos |
String | exactly-once |
No | No | Transfer Quality of Service (choices: at-most-once, at-least-once, exactly-once) |
<swiftlet name="xt$amqpbridge">
<bridges100>
<bridge100 name="..."/>
</bridges100>
</swiftlet>
<source> in <bridges100>
Source
| Parameter | Type | Default | Mandatory | Reboot Required | Description |
|---|---|---|---|---|---|
remote-hostname |
String | localhost |
No | No | Remote Host |
remote-port |
Integer | 5672 |
No | No | Remote Port |
use-ssl |
Boolean | false |
No | No | Establishes a SSL Connection |
sasl-enabled |
Boolean | true |
No | No | Enables/Disables SASL Authentication |
sasl-anonymous-login |
Boolean | true |
No | No | Use SASL Anonymous Login |
sasl-loginname |
String | — | No | No | SASL Loginname |
sasl-password |
String | — | No | No | SASL Password |
sasl-mechanism |
String | PLAIN |
No | No | SASL Mechanism |
source-address |
String | sourcequeue |
No | No | Source Address |
source-message-selector |
String | — | No | No | Source Message Selector |
connection-template |
String | default |
No | No | Connection Template |
<target> in <bridges100>
Target
| Parameter | Type | Default | Mandatory | Reboot Required | Description |
|---|---|---|---|---|---|
remote-hostname |
String | localhost |
No | No | Remote Host |
remote-port |
Integer | 5672 |
No | No | Remote Port |
use-ssl |
Boolean | false |
No | No | Establishes a SSL Connection |
sasl-enabled |
Boolean | true |
No | No | Enables/Disables SASL Authentication |
sasl-anonymous-login |
Boolean | true |
No | No | Use SASL Anonymous Login |
sasl-loginname |
String | — | No | No | SASL Loginname |
sasl-password |
String | — | No | No | SASL Password |
sasl-mechanism |
String | PLAIN |
No | No | SASL Mechanism |
target-address |
String | targetqueue |
No | No | Target Address |
connection-template |
String | default |
No | No | Connection Template |
<bridges091> in <swiftlet name="xt$amqpbridge">
AMQP 0.9.1 Bridges
Each <bridge091> entry is identified by its name attribute (the AMQP 0.9.1 Bridge).
| Parameter | Type | Default | Mandatory | Reboot Required | Description |
|---|---|---|---|---|---|
enabled |
Boolean | false |
No | No | Enables/Disables this Connection |
retryinterval |
Long | 60000 |
No | No | Retry Interval (ms) for Re-Connect |
<swiftlet name="xt$amqpbridge">
<bridges091>
<bridge091 name="..."/>
</bridges091>
</swiftlet>
<source> in <bridges091>
Source
| Parameter | Type | Default | Mandatory | Reboot Required | Description |
|---|---|---|---|---|---|
connect-uri |
String | amqp://admin:secret@localhost:5672/ |
No | No | AMQP Connect URI to create the Connection |
use-ssl |
Boolean | false |
No | No | Establishes a SSL Connection |
exchange-name |
String | — | No | No | Exchange Name |
exchange-type |
String | direct |
No | No | Exchange Type |
consumer-tag |
String | — | No | No | Consumer Tag |
queue-name |
String | — | No | No | Queue Name |
queue-option-durable |
Boolean | false |
No | No | Queue is durable? |
queue-option-exclusive |
Boolean | false |
No | No | Queue is exclusive? |
queue-option-autodelete |
Boolean | false |
No | No | Queue is autodelete? |
routing-key |
String | — | No | No | Routing Key |
<target> in <bridges091>
Target
| Parameter | Type | Default | Mandatory | Reboot Required | Description |
|---|---|---|---|---|---|
connect-uri |
String | amqp://admin:secret@localhost:5672/ |
No | No | AMQP Connect URI to create the Connection |
use-ssl |
Boolean | false |
No | No | Establishes a SSL Connection |
exchange-name |
String | — | No | No | Exchange Name |
routing-key |
String | — | No | No | Routing Key |