Starlight for RabbitMQ protocol handler
Following the protocol handler interface, Starlight for RabbitMQ constructs a "gateway" service that acts as a RabbitMQ cluster replacement.
RabbitMQ employs the concepts of Exchanges, Queues, and Bindings to provide basic routing capabilities inside the message broker.
Starlight for RabbitMQ acts as intermediary between RabbitMQ’s AMQP protocol and Pulsar’s binary protocol.
The result allows RabbitMQ applications to leverage Pulsar features like load balancing of the topics on the brokers, batching of messages, partitioning of topics, and load balancing of the data on the consumers.
Publishing messages
On the publishing side, an AMQP exchange is mapped to a topic. Depending on the type of exchange, the publish routing key can also be included in the topic name.
Consuming messages
On the consumer side, Pulsar shared subscriptions are used to represent the AMQP Bindings from an Exchange to a Queue.
When creating an AMQP Queue consumer, the protocol handler creates Pulsar consumers for all the Bindings of the Queue.
When you unbind the Queue, the Pulsar subscription isn’t deleted right away since the consumer can be lagging.
Messages are still received from the subscription and filtered if their position is past the end of the binding.
Starlight for RabbitMQ periodically checks if all messages from the closed binding have been acknowledged.
Once the messages have been acknowledged, the corresponding subscription is removed.
|
For more details on the AMQP 0.9.1 model refer to the AMQP 0-9-1 Model Explained guide in RabbitMQ documentation. |
Mapping AMQP entity constructs to Pulsar constructs
| RabbitMQ | Pulsar | Description |
|---|---|---|
Virtual host |
Tenant/Namespace |
vHosts map to the combination of your Pulsar tenant and a namespace within that tenant. See Multi-tenancy and VHosts. |
Exchange and optional Routing Key |
Topic Name |
The exchange name is the topic name. If the optional routing key is provided, then the exchange name and key are combined with a double underscore ( |
Queue and Bindings |
Consumer subscriptions |
A collection of Pulsar consumer shared subscriptions that represent all bindings in the queue. |
Multi-tenancy and VHosts
Starlight for RabbitMQ offers support for multi-tenancy by mapping an AMQP Virtual host to a Pulsar tenant and namespace.
|
This mapping requires that the AMQP VHost names contain only characters that are allowed in Pulsar tenant and namespace names: |
Full VHost names map directly to a Pulsar tenant and namespace.
For example, an AMQP VHost named /vhost1/abc maps to the Pulsar tenant and namespace vhost1/abc.
If the VHost name is empty (/) or short (/HOSTNAME or HOSTNAME), then Starlight for RabbitMQ completes the mapping based on the following parameters:
| Name | Default | Description |
|---|---|---|
|
|
Default Pulsar tenant used to map empty or short VHosts. |
|
|
Default Pulsar namespace used to map empty or short VHosts. |
|
|
Whether to prefer the
|
To further illustrate this concept, here is how Starlight for RabbitMQ handles different AMQP VHost names:
-
Empty VHost: An AMQP VHost
/maps toamqpDefaultTenant/amqpDefaultNamespace. For example, with the default values,/maps to the Pulsar namespacepublic/default. -
Short VHost: A short AMQP VHost, such as
/HOSTNAMEorHOSTNAMEmaps toamqpDefaultTenant/HOSTNAMEby default. The value ofamqpDefaultTenantis the Pulsar tenant name, and the VHost name is the namespace name. For example, ifamqpDefaultTenantis set topublic, then/vhost1andvhost1map to the Pulsar namespacepublic/vhost1.However, if
amqpMapShortVhostToTenantis set totrue, then the mapping isHOSTNAME/amqpDefaultNamespace. In this case, the VHost name is the Pulsar tenant name, and the value ofamqpDefaultNamespaceis the namespace name. For example, ifamqpDefaultNamespaceis set todefault, then/vhost1andvhost1map tovhost1/default. -
Full VHost: An AMQP VHost with who two segments, such as
/HOSTNAME/HOSTNAME_SUFFIXorHOSTNAME/HOSTNAME_SUFFIX, maps directly to a Pulsar tenant and namespace. The first segment is the tenant name, and the second segment is the namespace name.In this case, Starlight for RabbitMQ doesn’t use
amqpDefaultTenantoramqpDefaultNamespacebecause both names are explicitly provided.
Supported exchange types
Refer to RabbitMQ Exchanges and Exchange Types documentation for more.
-
Direct (default)
-
Fanout