This page refers to the deprecated legacy Azure Service Bus transport that uses the WindowsAzure.ServiceBus NuGet package. All users should migrate to the Azure Service Bus transport transport.
Prerequisites
An environment variable named AzureServiceBus.
with the connection string for the Azure Service Bus namespace.
Azure Service Bus Transport
This sample uses the Azure Service Bus Transport (Legacy).
Code walk-through
This sample shows a simple two endpoint scenario.
Endpoint1
sends aMessage1
message toEndpoint2
.Endpoint2
replies toEndpoint1
with aMessage2
.
Azure Service Bus configuration
The Server
endpoint is configured to use the Azure Table persistence in two locations.
var endpointConfiguration = new EndpointConfiguration("Samples.Azure.ServiceBus.Endpoint1");
endpointConfiguration.SendFailedMessagesTo("error");
#pragma warning disable 618
var transport = endpointConfiguration.UseTransport<AzureServiceBusTransport>();
#pragma warning restore 618
var connectionString = Environment.GetEnvironmentVariable("AzureServiceBus.ConnectionString");
if (string.IsNullOrWhiteSpace(connectionString))
{
throw new Exception("Could not read the 'AzureServiceBus.ConnectionString' environment variable. Check the sample prerequisites.");
}
transport.ConnectionString(connectionString);
transport.UseForwardingTopology();
Some things to note:
- The use of the
SamplesAzureServiceBusConnection
environment variable mentioned above.
Viewing message in-flight
The following queues for the two endpoints can be seen in the Azure Portal or a 3rd party tool:
samples.
azure. servicebus. endpoint1 samples.
azure. servicebus. endpoint2 error