Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ServiceBus] update migration guide with message count info #20360

Merged
2 commits merged into from
Aug 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions sdk/servicebus/azure-servicebus/migration_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,8 @@ In V7 of this library, we simplified this as below:

### Working with Administration Client

In v0.50, you could create/get/update/delete/list Service Bus queues/topics/subscriptions/rules using the `control_client`.
In v7, this is replaced by the `ServiceBusAdministrationClient`.
The following code snippets show how to manage queues, similar methods are provided on the `ServiceBusAdministrationClient` to manage topics, subscriptions and rules.
In v0.50, you could create/get/update/delete/list Service Bus queues/topics/subscriptions/rules using the `control_client`. You were also able to retrieve associated metadata, like `message_count`.
In v7, this is replaced by the `ServiceBusAdministrationClient`. The property `total_message_count` on `QueueRuntimeProperties` has now replaced `message_count` on `Queue`. More specific properties about message counts - `active_message_count`, `scheduled_message_count` and `dead_letter_message_count` - are also available. Similar methods are provided on the `ServiceBusAdministrationClient` to manage topics, subscriptions and rules. The following code snippets show how to manage queues and retrieve associated metadata.

In V0.50:
```python
Expand All @@ -374,6 +373,10 @@ queue = service_bus_service.get_queue(queue_name)
service_bus_service.create_queue(queue_name)
service_bus_service.delete_queue(queue_name)
queues = service_bus_service.list_queues()

# get message count info
for queue in queues:
print(queue.message_count)
```

In V7:
Expand All @@ -384,6 +387,14 @@ queue = service_bus_administration_client.get_queue(queue_name)
service_bus_administration_client.create_queue(queue_name)
service_bus_administration_client.delete_queue(queue_name)
queues = service_bus_administration_client.list_queues()

# get total, active, scheduled, dead-letter message count info
for queue in queues:
queue_runtime_properties = service_bus_administration_client.get_queue_runtime_properties(queue.name)
print(queue_runtime_properties.total_message_count)
print(queue_runtime_properties.active_message_count)
print(queue_runtime_properties.scheduled_message_count)
print(queue_runtime_properties.dead_letter_message_count)
```

### Migration samples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ async def get_queue_runtime_properties(servicebus_mgmt_client):
print("Updated at:", queue_runtime_properties.updated_at_utc)
print("Size in Bytes:", queue_runtime_properties.size_in_bytes)
print("Message Count:", queue_runtime_properties.total_message_count)
print("Active Message Count:", queue_runtime_properties.active_message_count)
print("Scheduled Message Count:", queue_runtime_properties.scheduled_message_count)
print("Dead-letter Message Count:", queue_runtime_properties.dead_letter_message_count)
print("Please refer to QueueRuntimeProperties from complete available runtime properties.")
print("")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,15 @@ def get_and_update_queue(servicebus_mgmt_client):

def get_queue_runtime_properties(servicebus_mgmt_client):
print("-- Get Queue Runtime Properties")
get_queue_runtime_properties = servicebus_mgmt_client.get_queue_runtime_properties(QUEUE_NAME)
print("Queue Name:", get_queue_runtime_properties.name)
queue_runtime_properties = servicebus_mgmt_client.get_queue_runtime_properties(QUEUE_NAME)
print("Queue Name:", queue_runtime_properties.name)
print("Queue Runtime Properties:")
print("Updated at:", get_queue_runtime_properties.updated_at_utc)
print("Size in Bytes:", get_queue_runtime_properties.size_in_bytes)
print("Message Count:", get_queue_runtime_properties.total_message_count)
print("Updated at:", queue_runtime_properties.updated_at_utc)
print("Size in Bytes:", queue_runtime_properties.size_in_bytes)
print("Message Count:", queue_runtime_properties.total_message_count)
print("Active Message Count:", queue_runtime_properties.active_message_count)
print("Scheduled Message Count:", queue_runtime_properties.scheduled_message_count)
print("Dead-letter Message Count:", queue_runtime_properties.dead_letter_message_count)
print("Please refer to QueueRuntimeProperties from complete available runtime properties.")
print("")

Expand Down