Skip to content

Commit 0464022

Browse files
committed
Editorial improvements.
1 parent e0698f0 commit 0464022

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

articles/iot-hub/iot-hub-amqp-support.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ As shown above, a C2D feedback message has content type of `application/vnd.micr
122122
* Key `originalMessageId` in feedback body has the ID of the original C2D message sent by the service. This can be used to correlate feedback to C2D messages.
123123

124124
### Receive telemetry messages (service client)
125-
By default, IoT Hub stores ingested device telemetry messages in a build-in Event Hubs. Your service client can use the AMQP protocol to receive the stored events.
125+
By default, IoT Hub stores ingested device telemetry messages in a built-in Event hub. Your service client can use the AMQP protocol to receive the stored events.
126126

127-
For this purpose, the service client first needs to connect to the IoT Hub endpoint and receive a redirection address to the built-in Event Hubs. Service client then uses the provided address to connect to the built-in Event Hub.
127+
For this purpose, the service client first needs to connect to the IoT Hub endpoint and receive a redirection address to the built-in Event Hubs. Service client then uses the provided address to connect to the built-in Event hub.
128128

129129
In each step, the client needs to present the following pieces of information:
130-
* Valid service credentials (SAS token);
131-
* A well-formatted path to the consumer group partition it intends to retrieve messages from;
130+
* Valid service credentials (service SAS token).
131+
* A well-formatted path to the consumer group partition it intends to retrieve messages from. For a given consumer group and partition ID, the path has the following format: `/messages/events/ConsumerGroups/<consumer_group>/Partitions/<partition_id>` (the default consumer group is `$Default`).
132132
* An optional filtering predicate to designate a starting point in the partition (this can be in the form of a sequence number, offset or enqueued timestamp).
133133

134134
The code snippet below uses [uAMQP library in Python](https://github.com/Azure/azure-uamqp-python) to demonstrate the above steps.
@@ -146,14 +146,18 @@ iot_hub_name = '<iot-hub-name>'
146146
hostname = '{iot_hub_name}.azure-devices.net'.format(iot_hub_name=iot_hub_name)
147147
policy_name = 'service'
148148
access_key = '<primary-or-secondary-key>'
149-
operation = '/messages/events/ConsumerGroups/{consumer_group}/Partitions/{p_id}'.format(consumer_group='$Default', p_id=2)
149+
operation = '/messages/events/ConsumerGroups/{consumer_group}/Partitions/{p_id}'.format(consumer_group='$Default', p_id=0)
150150

151151
username = '{policy_name}@sas.root.{iot_hub_name}'.format(policy_name=policy_name, iot_hub_name=iot_hub_name)
152152
sas_token = generate_sas_token(hostname, access_key, policy_name)
153153
uri = 'amqps://{}:{}@{}{}'.format(urllib.quote_plus(username), urllib.quote_plus(sas_token), hostname, operation)
154154

155-
# Following variable captures optional filtering predicates
156-
# Set this variable to None if no filter is needed
155+
# Optional filtering predicates can be specified using endpiont_filter
156+
# Valid predicates include:
157+
# - amqp.annotation.x-opt-sequence-number
158+
# - amqp.annotation.x-opt-offset
159+
# - amqp.annotation.x-opt-enqueued-time
160+
# Set endpoint_filter variable to None if no filter is needed
157161
endpoint_filter = b'amqp.annotation.x-opt-sequence-number > 2995'
158162

159163
# Helper function to set the filtering predicate on the source URI
@@ -182,7 +186,7 @@ for msg in batch:
182186
print('\t: ' + str(msg.annotations['x-opt-enqueued-time']))
183187
```
184188

185-
Even though the code snippet above demonstrates receiving events from a single partition ID, a typical application often needs to retrieve events stored on all the hub partitions.
189+
For a given device ID, IoT Hub uses a hash of the device ID to determine which partition to store messages in. Furthermore, note that even though the code snippet above demonstrates receiving events from a single partition ID, a typical application often needs to retrieve events stored on all the hub partitions.
186190

187191

188192
### Additional notes

0 commit comments

Comments
 (0)