服務匯流排分割區可讓佇列和主題 (或傳訊實體) 分割到多個訊息代理程式。 分割表示分割實體的整體輸送量不再受到單一訊息代理程式效能的限制。 此外,例如在升級期間發生訊息代理程式暫時性中斷,也不會使分割的佇列或主題無法使用。 分割的佇列和主題可以包含所有進階的服務匯流排功能,例如支援交易和工作階段。 如需相關資訊,請參閱 分割佇列和主題。 本文將告訴您啟用服務匯流排或主題分割的不同方法。
這很重要
- 在 Basic 或 Standard SKU 中,所有佇列與主題都可在建立實體時啟用分割。
- 無法更改任何現有佇列或主題的分割選項。 你只能在建立佇列或主題時設定這個選項。
- 在 標準 層命名空間中,你可以建立 1、2、3、4 或 5 GB 大小的服務匯流排佇列與主題(預設為 1 GB)。 啟用分割後,Azure 服務匯流排會建立 16 個相同大小的實體複本 (16 個分割區)。 因此,如果你建立一個大小為 5 GB、具有 16 個分割區的佇列,則其最大佇列大小會變為 (5 × 16) = 80 GB。
使用 Azure 入口網站
在 Azure 入口網站建立 佇列 時,請選擇 啟用分割, 如下圖所示。
在 Azure 入口網站建立主題時,請選擇啟用分割 , 如下圖所示。
使用 Azure CLI
若要建立已啟用分割的佇列,請使用 az servicebus queue create 命令,並將 --enable-partitioning 設為 true。
az servicebus queue create \
--resource-group myresourcegroup \
--namespace-name mynamespace \
--name myqueue \
--enable-partitioning true
要 建立已啟用分割的主題,請使用將 az servicebus topic create 設定為 --enable-partitioning 的 true 指令。
az servicebus topic create \
--resource-group myresourcegroup \
--namespace-name mynamespace \
--name mytopic \
--enable-partitioning true
使用 Azure PowerShell
若要建立已啟用分割的佇列,請使用 New-AzServiceBusQueue 命令,並將 -EnablePartitioning 設為 $True。
New-AzServiceBusQueue -ResourceGroup myresourcegroup `
-NamespaceName mynamespace `
-QueueName myqueue `
-EnablePartitioning $True
要 建立已啟用分割的主題,請使用將 New-AzServiceBusTopic 設定為 -EnablePartitioning 的 true 指令。
New-AzServiceBusTopic -ResourceGroup myresourcegroup `
-NamespaceName mynamespace `
-Name mytopic `
-EnablePartitioning $True
使用範本
要建立啟用分割的佇列,請在佇列屬性區段中將enablePartitioning設定為true。 欲了解更多資訊,請參閱 Microsoft.ServiceBus 命名空間/佇列範本參考。
@description('Name of the Service Bus namespace')
param serviceBusNamespaceName string
@description('Name of the Queue')
param serviceBusQueueName string
@description('Location for all resources.')
param location string = resourceGroup().location
resource serviceBusNamespace 'Microsoft.ServiceBus/namespaces@2024-01-01' = {
name: serviceBusNamespaceName
location: location
sku: {
name: 'Standard'
}
resource queue 'queues' = {
name: serviceBusQueueName
properties: {
enablePartitioning: true
}
}
}
要建立啟用分區的主題,請在主題屬性區塊中將enablePartitioning設定為true。 欲了解更多資訊,請參閱 Microsoft.ServiceBus 命名空間/主題範本參考。
@description('Name of the Service Bus namespace')
param serviceBusNamespaceName string
@description('Name of the Topic')
param serviceBusTopicName string
@description('Location for all resources.')
param location string = resourceGroup().location
resource serviceBusNamespace 'Microsoft.ServiceBus/namespaces@2024-01-01' = {
name: serviceBusNamespaceName
location: location
sku: {
name: 'Standard'
}
resource topic 'topics' = {
name: serviceBusTopicName
properties: {
enablePartitioning: true
}
}
}
後續步驟
請以您所選擇的語言嘗試各式範例,以探索 Azure 服務匯流排的功能。