tencent cloud

Feedback

Basic Concepts

Last updated: 2024-10-18 17:35:37
    This document mainly introduces common terms and their explanations used in TDMQ for RabbitMQ.

    Binding

    In RabbitMQ, a Binding associates an Exchange with a Queue, allowing RabbitMQ to know how to correctly route messages to the specified Queue.

    Binding key

    When you bind an Exchange with a Queue, a binding key is usually specified. When the producer sends a message to the Exchange, it generally includes a routing key. If the binding key matches the routing key, the message will be routed to the corresponding Queue.
    When you bind multiple Queues to the same Exchange, these Bindings can use the same binding key.
    The binding key is not always effective in all situations; it depends on the Exchange type. For example, a fanout Exchange ignores the binding key and routes messages to all Queues bound to that Exchange.

    Channel

    Within each physical TCP connection from a client, multiple Channels can be established, with each Channel representing a session task.

    Connection

    A TCP connection is the physical connection established between the producer or consumer and TDMQ for RabbitMQ.

    Exchange

    Producers send messages to an Exchange, which then routes the messages to one or more Queues (or discards them). The Exchange routes messages based on their attributes or content.

    Exchange Types

    RabbitMQ commonly uses Exchange Types such as fanout, direct, topic, and header.
    Fanout: A fanout Exchange routes all messages sent to it to every Queue bound to it.
    Direct: A direct Exchange routes messages to Queues where the binding key exactly matches the routing key.
    Topic: Similar to the direct type, a topic Exchange supports multi-condition and fuzzy matching. It routes messages to the bound Queues by pattern matching and string comparison using the routing key.
    Header: This type of Exchange is unrelated to the routing key. Instead, the matching mechanism relies on the Headers attribute information in the message. Before a Queue is bound to a Headers Exchange, a map key-value pair is declared. This map object is used to bind the Queue and Exchange. When a message is sent to RabbitMQ, its headers are checked against the key-value pair specified during the binding process. If the headers match exactly, the message is routed to the corresponding Queue; otherwise, it is not.

    Message Acknowledgment

    Message acknowledgment: After a message is consumed, the consumer sends an acknowledgment to RabbitMQ. RabbitMQ only deletes the message from the queue after receiving this acknowledgment. If RabbitMQ does not receive the acknowledgment and detects that the consumer’s connection has been closed, it will resend the message to another consumer for processing.

    Message Durability

    Message durability: Message durability ensures that messages are not lost even if the RabbitMQ service restarts. Both the Queue and Message can be set to durable, which guarantees that in most cases, RabbitMQ messages will not be lost.

    Prefetch Count

    When consumers have message acknowledgment enabled, they can asynchronously acknowledge messages based on their business needs. The prefetch setting allows for specifying the maximum number of unacknowledged messages per consumer. For example, if prefetchCount=10 is set, the Queue will send 10 messages to each consumer (assuming there are two consumers, A and B). The consumers do not need to respond immediately and can cache the 10 messages locally. Once a consumer processes and acknowledges a message, the Queue will send another message to that consumer. If neither consumer acknowledges any message, the Queue will not continue sending new messages.

    Queue

    A Queue in RabbitMQ is an internal object used for storing messages. Each message will be placed into one or more Queues.

    Routing key

    When a producer sends a message to an Exchange, a routing key is typically specified to define the routing rules for the message. This routing key should be used in conjunction with the Exchange Type and binding key for it to take effect.
    In a scene where the Exchange Type and binding key are fixed (which is usually the case during regular use), the producer can determine the destination of the message by specifying the routing key when sending the message to the Exchange.

    Vhost

    A virtual host (Vhost) is used for logical isolation, allowing the separate management of individual Exchanges, Queues, and Bindings. This ensures that applications run securely on different Vhost instances without interfering with each other. A single instance can have multiple Vhosts, and each Vhost can contain several Exchanges and Queues. When connecting to TDMQ for RabbitMQ, both producers and consumers need to specify a Vhost.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support