Skip to content

Commit de16b27

Browse files
committed
ServiceBus crate
Initial ServiceBus crate Create the initial structure for the ServiceBus crate. Includes tests, docs, and the basic clients: - Client - Sender - Receiver - Message Types - Error handling
1 parent 84fd946 commit de16b27

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+13482
-1
lines changed

.vscode/cspell.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@
124124
"path": "../sdk/keyvault/.dict.txt",
125125
"noSuggest": true
126126
},
127+
{
128+
"name": "servicebus",
129+
"path": "../sdk/servicebus/.dict.txt",
130+
"noSuggest": true
131+
},
127132
{
128133
"name": "storage",
129134
"path": "../sdk/storage/.dict.txt",
@@ -202,6 +207,14 @@
202207
"cosmos"
203208
]
204209
},
210+
{
211+
"filename": "sdk/servicebus/**",
212+
"dictionaries": [
213+
"crates",
214+
"rust-custom",
215+
"servicebus"
216+
]
217+
},
205218
{
206219
"filename": "sdk/storage/**",
207220
"dictionaries": [
@@ -211,4 +224,4 @@
211224
]
212225
}
213226
]
214-
}
227+
}

Cargo.lock

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ members = [
1717
"sdk/keyvault/azure_security_keyvault_certificates",
1818
"sdk/keyvault/azure_security_keyvault_keys",
1919
"sdk/keyvault/azure_security_keyvault_secrets",
20+
"sdk/servicebus/azure_messaging_servicebus",
2021
"sdk/template/azure_template_core",
2122
"sdk/template/azure_template",
2223
"sdk/storage/azure_storage_common",

sdk/servicebus/.dict.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
amqps
2+
azuremessagingservicebus
3+
backoff
4+
mybus
5+
myqueue
6+
myservicebus
7+
retryable
8+
Retryable
9+
SubQueue
10+
subqueues
11+
testqueue
12+
testtopic
13+
testsubscription
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Release History
2+
3+
## 0.1.0 (Unreleased)
4+
5+
### Features Added
6+
7+
- Initial release of Azure Service Bus client library for Rust
8+
- Support for sending and receiving messages from Service Bus queues and topics
9+
- Support for session-enabled entities
10+
- Support for dead letter queues
11+
- AMQP-based implementation using azure_core_amqp
12+
13+
### Breaking Changes
14+
15+
### Bugs Fixed
16+
17+
### Other Changes
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Running Azure Service Bus Live Tests
2+
3+
This guide explains how to set up and run live integration tests for the Azure Service Bus SDK for Rust using the Azure SDK test infrastructure.
4+
5+
## Prerequisites
6+
7+
1. **Azure Subscription**: Access to the targeted subscription
8+
2. **Azure CLI**: Install and configure Azure CLI (`az login`)
9+
3. **Azure PowerShell**: Install PowerShell modules (`Install-Module Az -Force`)
10+
4. **Bicep**: For infrastructure deployment (`az bicep install`)
11+
5. **Permissions**: Contributor access to create resources in your subscription
12+
13+
## Automated Test Infrastructure Setup
14+
15+
The Azure SDK provides a standardized test infrastructure using the `New-TestResources.ps1` script with Bicep templates to automatically create and configure all required Azure Service Bus resources.
16+
17+
### Deploy Test Resources
18+
19+
From the repository root, run:
20+
21+
```powershell
22+
# Set subscription
23+
az account set --subscription "<Your Subscription Name>"
24+
25+
# Deploy test infrastructure
26+
./eng/common/TestResources/New-TestResources.ps1 servicebus/azure_messaging_servicebus -SubscriptionId <subscription ID>
27+
```
28+
29+
This will automatically create:
30+
31+
- Azure Service Bus namespace with Standard tier
32+
- Test queue named `testqueue`
33+
- Test topic named `testtopic` with subscription `testsubscription`
34+
- RBAC permissions for TokenCredential testing
35+
- All required environment variables
36+
37+
The script will output PowerShell commands to set environment variables.
38+
39+
### Environment Variables
40+
41+
After deployment completes successfully, the script will output commands like:
42+
43+
```powershell
44+
$env:SERVICEBUS_NAMESPACE = "sb-your-deployment-name.servicebus.windows.net"
45+
$env:SERVICEBUS_QUEUE_NAME = "testqueue"
46+
$env:SERVICEBUS_TOPIC_NAME = "testtopic"
47+
$env:SERVICEBUS_SUBSCRIPTION_NAME = "testsubscription"
48+
```
49+
50+
## Run Live Tests
51+
52+
Once the environment variables are set, run the tests:
53+
54+
**All Live Tests:**
55+
56+
```powershell
57+
cd sdk\servicebus\azure_messaging_servicebus
58+
cargo test
59+
```
60+
61+
## Debugging
62+
63+
Enable debug logging for detailed information:
64+
65+
```powershell
66+
$env:RUST_LOG = "debug"
67+
cargo test
68+
```
69+
70+
For detailed AMQP protocol debugging:
71+
72+
```powershell
73+
$env:RUST_LOG = "azure_messaging_servicebus=debug,azure_core_amqp=debug"
74+
cargo test
75+
```
76+
77+
## Expected Test Behavior
78+
79+
- **TokenCredential Tests**: Will skip if not properly configured (not a failure)
80+
- **Test Duration**: Each test typically takes 10-30 seconds due to network operations
81+
- **Resource Cleanup**: Tests automatically complete/delete sent messages
82+
83+
## Troubleshooting
84+
85+
### Deployment Issues
86+
87+
- Ensure you're logged into Azure CLI: `az login`
88+
- Verify you have Contributor permissions on the subscription
89+
- Check that the resource group name doesn't already exist
90+
- Ensure Service Bus is available in your selected region
91+
92+
### Authentication Issues
93+
94+
- For TokenCredential tests, ensure you're logged in via Azure CLI
95+
- RBAC permissions are automatically configured during deployment
96+
- Service principal credentials can be set via environment variables if needed
97+
98+
### Test Execution Issues
99+
100+
- Verify all environment variables are set correctly
101+
- Check that Service Bus resources are in "Active" status
102+
- Ensure network connectivity to Azure Service Bus
103+
- Review test output for specific error messages
104+
105+
## Resource Cleanup
106+
107+
When you're finished testing, clean up the resources:
108+
109+
```powershell
110+
# Clean up test resources
111+
./eng/common/TestResources/Remove-TestResources.ps1 servicebus/azure_messaging_servicebus
112+
```
113+
114+
## Performance Notes
115+
116+
- Live tests create real network connections
117+
- Messages are sent to actual Azure Service Bus queues
118+
- Consider using a dedicated test namespace
119+
- Tests include cleanup operations (complete/delete messages)
120+
- Some tests may have delays for timing validation
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright (c) Microsoft Corp. All Rights Reserved.
2+
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
[package]
5+
name = "azure_messaging_servicebus"
6+
version = "0.1.0"
7+
description = "Rust client for Azure Service Bus"
8+
readme = "README.md"
9+
authors.workspace = true
10+
license.workspace = true
11+
repository.workspace = true
12+
homepage = "https://github.com/azure/azure-sdk-for-rust"
13+
documentation = "https://docs.rs/azure_messaging_servicebus"
14+
15+
keywords = ["sdk", "azure", "messaging", "cloud", "servicebus"]
16+
categories = ["api-bindings"]
17+
18+
edition.workspace = true
19+
20+
[dependencies]
21+
async-lock.workspace = true
22+
async-stream.workspace = true
23+
async-trait.workspace = true
24+
azure_core.workspace = true
25+
azure_core_amqp.workspace = true
26+
futures.workspace = true
27+
rand.workspace = true
28+
rand_chacha.workspace = true
29+
serde = { workspace = true, features = ["derive"] }
30+
time.workspace = true
31+
tracing.workspace = true
32+
url.workspace = true
33+
uuid.workspace = true
34+
35+
[dev-dependencies]
36+
azure_core_amqp = { workspace = true, features = ["test"] }
37+
azure_core_test = { workspace = true, features = ["tracing"] }
38+
azure_identity.workspace = true
39+
azure_messaging_servicebus = { path = "." }
40+
serde_json.workspace = true
41+
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
42+
tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] }
43+
44+
[lints]
45+
workspace = true

0 commit comments

Comments
 (0)