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

Service Bus Migration Guide improvements #14166

Merged
merged 18 commits into from
Sep 10, 2020
Merged
Changes from 1 commit
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
15 changes: 8 additions & 7 deletions sdk/servicebus/Azure.Messaging.ServiceBus/MigrationGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,13 @@ ServiceBusMessageBatch messageBatch = await sender.CreateMessageBatchAsync();
for (var i = 0; i < 10; i++)
{
// create a message
ServiceBusMessage message = new ServiceBusMessage("Hello world!" + i);
ServiceBusMessage message = new ServiceBusMessage($"Hello world! - {i}");

// Add message the batch
var tryAddResult = messageBatch.TryAddMessage((message);
if (!tryAddResult) {
Console.WriteLine("Failed to add message number " + i);
if (!tryAddResult)
{
Console.WriteLine($"Failed to add message number {i}");
break;
}
}
Expand Down Expand Up @@ -194,8 +195,8 @@ await processor.StartProcessingAsync();

// Or receive using the receiver
var receiver = client.CreateReceiver(queueName);
var receivedMessage = await receiver.ReceiveAsync();
Console.WriteLine($"Received message with Body:{Encoding.UTF8.GetString(receivedMessage.Body)}");
var receivedMessage = await receiver.ReceiveMessageAsync();
Console.WriteLine($"Received message with Body: {receivedMessage.Body}");
await receiver.CompleteMessageAsync(receivedMessage);

```
Expand Down Expand Up @@ -232,14 +233,14 @@ You have similar options when working with the receivers. Please note that creat

```cs
// create a receiver to receive events from the next available session
await ServiceBusReceiver receiver = client.CreateSessionReceiver(queueName);
ServiceBusSessionReceiver receiver = await client.CreateSessionReceiver(queueName);

// create a receiver to receive events from the given session
var options = new ServiceBusSessionReceiverOptions
{
SessionId = "my-session"
};
await ServiceBusReceiver receiver = client.CreateSessionReceiver(queueName, options);
ServiceBusSessionReceiver receiver = await client.CreateSessionReceiver(queueName, options);
```

## Additional samples
Expand Down