来自 Azure 流分析的服务总线主题输出Service Bus Topics output from Azure Stream Analytics

服务总线队列提供从发送方到接收方的一对一通信方法。Service Bus queues provide a one-to-one communication method from sender to receiver. 服务总线主题提供一对多形式的通信。Service Bus topics provide a one-to-many form of communication.

下表列出了用于创建服务总线主题输出的属性名称及其说明。The following table lists the property names and their descriptions for creating a Service Bus topic output.

属性名称Property name 说明Description
输出别名Output alias 该名称是在查询中使用的易记名称,用于将查询输出定向到此服务总线主题。A friendly name used in queries to direct the query output to this Service Bus topic.
服务总线命名空间Service Bus namespace 包含一组消息实体的容器。A container for a set of messaging entities. 创建新的事件中心后,还创建了 Service Bus 命名空间。When you created a new event hub, you also created a Service Bus namespace.
主题名称Topic name 主题是消息传递实体,类似于事件中心和队列。Topics are messaging entities, similar to event hubs and queues. 设计用于从设备和服务收集事件流。They're designed to collect event streams from devices and services. 在创建主题时,还会为其提供特定的名称。When a topic is created, it's also given a specific name. 发送到主题的消息在创建订阅后才会提供给用户,因此请确保主题下存在一个或多个订阅The messages sent to a topic aren't available unless a subscription is created, so ensure there's one or more subscriptions under the topic.
主题策略名称Topic policy name 创建服务总线主题时,还可以在主题的“配置”选项卡上创建共享的访问策略。每个共享访问策略具有名称、所设权限以及访问密钥。When you create a Service Bus topic, you can also create shared access policies on the topic's Configure tab. Each shared access policy has a name, permissions that you set, and access keys.
主题策略密钥Topic policy key 用于对服务总线命名空间的访问权限进行身份验证的共享访问密钥。The shared access key that's used to authenticate access to the Service Bus namespace.
事件序列化格式Event serialization format 输出数据的序列化格式。The serialization format for output data. 支持 JSON、CSV 和 Avro。JSON, CSV, and Avro are supported.
编码Encoding 如果使用 CSV 或 JSON 格式,则必须指定一种编码格式。If you're using CSV or JSON format, an encoding must be specified. 目前只支持 UTF-8 这种编码格式。UTF-8 is the only supported encoding format at this time.
分隔符Delimiter 仅适用于 CSV 序列化。Applicable only for CSV serialization. 流分析支持大量的常见分隔符以对 CSV 格式的数据进行序列化。Stream Analytics supports a number of common delimiters for serializing data in CSV format. 支持的值为逗号、分号、空格、制表符和竖线。Supported values are comma, semicolon, space, tab, and vertical bar.
属性列Property columns 可选。Optional. 需要作为传出消息(而不是有效负载)的用户属性附加的以逗号分隔的列。Comma-separated columns that need to be attached as user properties of the outgoing message instead of the payload. 输出的自定义元数据属性部分详细介绍了此功能。More information about this feature is in the section Custom metadata properties for output.
系统属性列System Property columns 可选。Optional. 需要附加到传出消息而不是附加到有效负载的系统属性和相应列名的键值对。Key value pairs of System Properties and corresponding column names that need to be attached to the outgoing message instead of the payload.

分区数基于服务总线 SKU 和大小The number of partitions is based on the Service Bus SKU and size. 分区键是每个分区的唯一整数值。The partition key is a unique integer value for each partition.

分区Partitioning

自动选择分区。Partitioning is automatically chosen. 分区数基于服务总线 SKU 和大小The number of partitions is based on the Service Bus SKU and size. 分区键是每个分区的唯一整数值。The partition key is a unique integer value for each partition. 输出写入器的数量与输出主题中的分区数相同。The number of output writers is the same as the number of partitions in the output topic.

输出批大小Output batch size

对于标准层,每条消息的最大消息大小为 256 KB,对于高级层则为 1MB。The maximum message size is 256 KB per message for Standard tier and 1MB for Premium tier. 有关详细信息,请参阅服务总线限制For more information, see Service Bus limits. 若要优化,请对每条消息使用单个事件。To optimize, use a single event per message.

输出的自定义元数据属性Custom metadata properties for output

可将查询列作为用户属性附加到传出的消息。You can attach query columns as user properties to your outgoing messages. 这些列不会进入有效负载。These columns don't go into the payload. 这些属性以字典形式在输出消息中提供。The properties are present in the form of a dictionary on the output message. 键是列名,值是属性字典中的列值。 Key is the column name and value is the column value in the properties dictionary. 支持除“记录”和“数组”以外的其他所有流分析数据类型。All Stream Analytics data types are supported except Record and Array.

在以下示例中,字段 DeviceIdDeviceStatus 添加到了元数据。In the following example, the fields DeviceId and DeviceStatus are added to the metadata.

  1. 使用以下查询:Use the following query:

    select *, DeviceId, DeviceStatus from iotHubInput
    
  2. DeviceId,DeviceStatus 配置为输出中的属性列。Configure DeviceId,DeviceStatus as property columns in the output.

    属性列

下图显示了在事件中心使用服务总线资源管理器检查的预期输出消息属性。The following image is of the expected output message properties inspected in EventHub using Service Bus Explorer.

事件自定义属性

系统属性System properties

可以将查询列作为系统属性附加到传出的服务总线队列或主题消息。You can attach query columns as system properties to your outgoing service bus Queue or Topic messages. 这些列不会进入有效负载,而是将查询列值填充到相应的 BrokeredMessage 系统属性中。These columns don't go into the payload instead the corresponding BrokeredMessage system property is populated with the query column values. 支持这些系统属性 - MessageId, ContentType, Label, PartitionKey, ReplyTo, SessionId, CorrelationId, To, ForcePersistence, TimeToLive, ScheduledEnqueueTimeUtcThese system properties are supported - MessageId, ContentType, Label, PartitionKey, ReplyTo, SessionId, CorrelationId, To, ForcePersistence, TimeToLive, ScheduledEnqueueTimeUtc.

这些列的字符串值将分析成相应的系统属性值类型,任何分析失败将被视为数据错误。String values of these columns are parsed as corresponding system property value type and any parsing failures are treated as data errors. 此字段以 JSON 对象格式提供。This field is provided as a JSON object format. 有关此格式的详细信息如下:Details about this format are as follows:

  • 用大括号 {} 括住。Surrounded by curly braces {}.
  • 以键值对的形式编写。Written in key/value pairs.
  • 键和值必须是字符串。Keys and values must be strings.
  • 键是系统属性名称,值是查询列名。Key is the system property name and value is the query column name.
  • 键和值以冒号分隔。Keys and values are separated by a colon.
  • 每个键值对以逗号分隔。Each key/value pair is separated by a comma.

下面演示了此属性的用法 -This shows how to use this property -

  • 查询:select *, column1, column2 INTO queueOutput FROM iotHubInputQuery: select *, column1, column2 INTO queueOutput FROM iotHubInput
  • 系统属性列:{ "MessageId": "column1", "PartitionKey": "column2"}System Property Columns: { "MessageId": "column1", "PartitionKey": "column2"}

这会在服务总线队列消息的 MessageId 中设置 column1 的值,并在 PartitionKey 中设置 column2 的值。This sets the MessageId on service bus queue messages with column1's values and PartitionKey is set with column2's values.

后续步骤Next steps