什麼是 Azure 服務匯流排?What is Azure Service Bus?

Microsoft Azure 服務匯流排是完全受控的企業整合訊息代理程式。Microsoft Azure Service Bus is a fully managed enterprise integration message broker. 服務匯流排可以將應用程式與服務分離。Service Bus can decouple applications and services. 服務匯流排針對非同步資料和狀態傳輸提供了可靠且安全的平台。Service Bus offers a reliable and secure platform for asynchronous transfer of data and state.

資料會使用「訊息」 在不同的應用程式和服務之間傳輸。Data is transferred between different applications and services using messages. 訊息採用二進位格式,且可包含 JSON、XML 或純文字。A message is in binary format and can contain JSON, XML, or just text. 如需詳細資訊,請參閱 Integration ServicesFor more information, see Integration Services.

一些常見的傳訊案例如下:Some common messaging scenarios are:

  • 傳訊Messaging. 傳輸商務資料,例如銷售或採購單、日誌或庫存移動。Transfer business data, such as sales or purchase orders, journals, or inventory movements.
  • 將應用程式分離Decouple applications. 改善應用程式和服務的可靠性和延展性。Improve reliability and scalability of applications and services. 用戶端和服務不需要同時上線。Client and service don't have to be online at the same time.
  • 主題和訂用帳戶Topics and subscriptions. 讓「發行者」與「訂閱者」之間有 1:n 的關聯性。Enable 1:n relationships between publishers and subscribers.
  • 訊息工作階段Message sessions. 實作需要訊息排序或訊息延遲的工作流程。Implement workflows that require message ordering or message deferral.

命名空間Namespaces

命名空間是所有訊息元件的容器。A namespace is a container for all messaging components. 多個佇列和主題可以位於單一命名空間中,且命名空間通常會作為應用程式容器。Multiple queues and topics can be in a single namespace, and namespaces often serve as application containers.

佇列Queues

「佇列」 會收發訊息。Messages are sent to and received from queues. 在接收端應用程式能夠接收並處理訊息之前,佇列會儲存訊息。Queues store messages until the receiving application is available to receive and process them.

佇列

佇列中的訊息會進行排序並加上抵達時間戳記。Messages in queues are ordered and timestamped on arrival. 訊息一經接受就會安全地保存在備援儲存體中。Once accepted, the message is held safely in redundant storage. 訊息會採用「提取」 模式來傳遞,而僅在收到要求時傳遞訊息。Messages are delivered in pull mode, only delivering messages when requested.

主題Topics

您也可以使用「主題」 來收送訊息。You can also use topics to send and receive messages. 佇列通常用於點對點通訊,主題則適用於發佈/訂閱案例。While a queue is often used for point-to-point communication, topics are useful in publish/subscribe scenarios.

主題

主題可以有多個獨立的訂用帳戶。Topics can have multiple, independent subscriptions. 主題的訂閱者會收到該主題所接收每則訊息的複本。A subscriber to a topic can receive a copy of each message sent to that topic. 訂用帳戶是具名實體。Subscriptions are named entities. 訂用帳戶會持續保存,但可能會到期或自動刪除。Subscriptions persist, but can expire or autodelete.

您可能會不想讓個別訂用帳戶接收某個主題所收到的所有訊息。You may not want individual subscriptions to receive all messages sent to a topic. 如果是這樣,您可以使用規則篩選來定義各種條件,以觸發選擇性動作If so, you can use rules and filters to define conditions that trigger optional actions. 您可以篩選指定的訊息,以及設定或修改訊息屬性。You can filter specified messages and set or modify message properties. 如需詳細資訊,請參閱主題篩選和動作For more information, see Topic filters and actions.

進階功能Advanced features

服務匯流排包含進階功能可讓您解決更複雜的傳訊問題。Service Bus includes advanced features that enable you to solve more complex messaging problems. 以下各節將說明其中幾項功能。The following sections describe several of these features.

訊息工作階段Message sessions

若要在服務匯流排中建立先進先出 (FIFO) 保證,請使用工作階段。To create a first-in, first-out (FIFO) guarantee in Service Bus, use sessions. 訊息工作階段能夠聯結和依序處理無限制的相關訊息序列。Message sessions enable joint and ordered handling of unbounded sequences of related messages. 如需詳細資訊,請參閱訊息工作階段:先進先出 (FIFO)For more information, see Message sessions: first in, first out (FIFO).

自動轉送Autoforwarding

自動轉送功能可將佇列或訂用帳戶鏈結至另一個佇列或主題。The autoforwarding feature chains a queue or subscription to another queue or topic. 它們必須是相同命名空間的一部分。They must be part of the same namespace. 透過自動轉送,服務匯流排會自動移除佇列或訂用帳戶中的訊息,並將其放在不同的佇列或主題中。With autoforwarding, Service Bus automatically removes messages from a queue or subscription and puts them in a different queue or topic. 如需詳細資訊,請參閱使用自動轉送鏈結服務匯流排實體For more information, see Chaining Service Bus entities with autoforwarding.

無效信件佇列Dead-letter queue

服務匯流排支援無效信件佇列 (DLQ)。Service Bus supports a dead-letter queue (DLQ). DLQ 會保存無法傳遞給任何接收者的訊息。A DLQ holds messages that can't be delivered to any receiver. 它會保存無法處理的訊息。It holds messages that can't be processed. 服務匯流排可讓您從 DLQ 中移除訊息並加以檢查。Service Bus lets you remove messages from the DLQ and inspect them. 如需詳細資訊,請參閱服務匯流排寄不出的信件佇列的概觀For more information, see Overview of Service Bus dead-letter queues.

排程傳遞Scheduled delivery

您可以將訊息提交至佇列或主題,以進行延遲處理。You can submit messages to a queue or topic for delayed processing. 您可以排定作業讓系統在某個時間處理。You can schedule a job to become available for processing by a system at a certain time. 如需詳細資訊,請參閱已排程的訊息For more information, see Scheduled messages.

訊息延遲Message deferral

佇列或訂用帳戶用戶端可將訊息的擷取延遲到稍後執行。A queue or subscription client can defer retrieval of a message until a later time. 此延遲可能是基於應用程式中的特殊情況而設定的。This deferral might be because of special circumstances in the application. 訊息會保留於佇列或訂用帳戶中,但會將它擱置於一旁。The message remains in the queue or subscription, but it's set aside. 如需詳細資訊,請參閱訊息延遲For more information, see Message deferral.

批次處理Batching

用戶端批次處理可讓佇列或主題用戶端將訊息的傳送延遲一段時間。Client-side batching enables a queue or topic client to delay sending a message for a certain period of time. 如果用戶端在此期間傳送其他訊息,它將以單一批次傳輸訊息。If the client sends additional messages during this time period, it transmits the messages in a single batch. 如需詳細資訊,請參閱用戶端批次處理For more information, see Client-side batching.

交易Transactions

交易會將兩個或更多作業一起分組到執行範圍中。A transaction groups two or more operations together into an execution scope. 服務匯流排支援對單一交易範圍內的單一傳訊實體進行分組作業。Service Bus supports grouping operations against a single messaging entity within the scope of a single transaction. 訊息實體可以是佇列、主題或訂用帳戶。A message entity can be a queue, topic, or subscription. 如需詳細資訊,請參閱服務匯流排交易處理概觀For more information, see Overview of Service Bus transaction processing.

篩選和動作Filtering and actions

訂閱者可以定義他們想要接收某個主題的哪些訊息。Subscribers can define which messages they want to receive from a topic. 這些訊息會以一或多個具名訂用帳戶規則的形式來指定。These messages are specified in the form of one or more named subscription rules. 對於每個比對規則條件,訂用帳戶會產生一份能針對每條比對規則加上不同註解的訊息。For each matching rule condition, the subscription produces a copy of the message, which can be differently annotated for each matching rule. 如需詳細資訊,請參閱主題篩選和動作For more information, see Topic filters and actions.

閒置時自動刪除Autodelete on idle

閒置時自動刪除可讓您指定閒置間隔,此時間過後就自動刪除佇列。Autodelete on idle enables you to specify an idle interval after which a queue is automatically deleted. 最小持續期間為 5 分鐘。The minimum duration is 5 minutes. 如需詳細資訊,請參閱 QueueDescription.AutoDeleteOnIdle 屬性For more information, see the QueueDescription.AutoDeleteOnIdle Property.

重複偵測Duplicate detection

錯誤可能會導致用戶端不確定傳送作業的結果。An error could cause the client to have a doubt about the outcome of a send operation. 重複項偵測可讓傳送者重新傳送相同的訊息。Duplicate detection enables the sender to resend the same message. 另一個選項是讓佇列或主題捨棄任何重複的複本。Another option is for the queue or topic to discard any duplicate copies. 如需詳細資訊,請參閱重複偵測For more information, see Duplicate detection.

安全性通訊協定Security protocols

服務匯流排支援安全性通訊協定,例如共用存取簽章 (SAS)、Azure 角色型存取控制 (Azure RBAC)Azure 資源的受控識別Service Bus supports security protocols such as Shared Access Signatures (SAS), Azure role-based access control (Azure RBAC) and Managed identities for Azure resources.

異地災害復原Geo-disaster recovery

當 Azure 區域或資料中心停止運作時,異地災害復原能繼續在不同的區域或資料中心進行資料處理。When Azure regions or datacenters experience downtime, Geo-disaster recovery enables data processing to continue operating in a different region or datacenter. 如需詳細資訊,請參閱 Azure 服務匯流排地理災害復原For more information, see Azure Service Bus Geo-disaster recovery.

安全性Security

服務匯流排支援標準的 AMQP 1.0HTTP/REST 通訊協定。Service Bus supports standard AMQP 1.0 and HTTP/REST protocols.

用戶端程式庫Client libraries

服務匯流排支援 .NETJavaJMS 用戶端程式庫。Service Bus supports client libraries for .NET, Java, and JMS.

整合Integration

服務匯流排可與下列 Azure 服務完全整合︰Service Bus fully integrates with the following Azure services:

後續步驟Next steps

若要開始使用服務匯流排傳訊,請參閱下列文章:To get started using Service Bus messaging, see the following articles: