-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add legacy transport bridge docs (#6117)
- Loading branch information
Showing
80 changed files
with
1,811 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using NServiceBus; | ||
|
||
public class API | ||
{ | ||
public void Configuration() | ||
{ | ||
var connectionString = string.Empty; | ||
var bridgeConfiguration = new BridgeConfiguration(); | ||
|
||
#region bridgeconfiguration | ||
|
||
var msmq = new BridgeTransport(new MsmqTransport()); | ||
var asb = new BridgeTransport(new AzureServiceBusTransport(connectionString)); | ||
|
||
msmq.HasEndpoint("Sales"); | ||
asb.HasEndpoint("Billing"); | ||
|
||
bridgeConfiguration.AddTransport(msmq); | ||
bridgeConfiguration.AddTransport(asb); | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<LangVersion>10.0</LangVersion> | ||
<TargetFramework>net48</TargetFramework> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="NServiceBus.Transport.AzureServiceBus" Version="3.*" /> | ||
<PackageReference Include="NServiceBus.Transport.Bridge" Version="1.*" /> | ||
<PackageReference Include="NServiceBus.Transport.Msmq" Version="2.*" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
namespace Bridge_1 | ||
{ | ||
using Messages; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Hosting; | ||
using NServiceBus; | ||
using System.Threading.Tasks; | ||
|
||
public class Configuration | ||
{ | ||
public async Task GenericHost() | ||
{ | ||
#region generic-host | ||
|
||
await Host.CreateDefaultBuilder() | ||
.UseNServiceBusBridge(bridgeConfiguration => | ||
{ | ||
// Configure the bridge | ||
}) | ||
.Build() | ||
.RunAsync(); | ||
|
||
#endregion | ||
} | ||
|
||
public async Task GenericHostBuilderContext() | ||
{ | ||
#region generic-host-builder-context | ||
|
||
await Host.CreateDefaultBuilder() | ||
.UseNServiceBusBridge((hostBuilderContext, bridgeConfiguration) => | ||
{ | ||
var connectionString = hostBuilderContext.Configuration.GetValue<string>("MyBridge:AzureServiceBusConnectionString"); | ||
var concurrency = hostBuilderContext.Configuration.GetValue<int>("MyBridge:Concurrency"); | ||
|
||
var transport = new BridgeTransport(new AzureServiceBusTransport(connectionString)) | ||
{ | ||
Concurrency = concurrency | ||
}; | ||
|
||
bridgeConfiguration.AddTransport(transport); | ||
|
||
// more configuration... | ||
}) | ||
.Build() | ||
.RunAsync().ConfigureAwait(false); | ||
|
||
#endregion | ||
} | ||
|
||
public async Task EndpointRegistration() | ||
{ | ||
#region endpoint-registration | ||
|
||
await Host.CreateDefaultBuilder() | ||
.UseNServiceBusBridge((ctx, bridgeConfiguration) => | ||
{ | ||
var msmq = new BridgeTransport(new MsmqTransport()); | ||
msmq.HasEndpoint("Sales"); | ||
msmq.HasEndpoint("Shipping"); | ||
|
||
var asb = new BridgeTransport(new AzureServiceBusTransport(connectionString)); | ||
asb.HasEndpoint("Finance.Invoicing"); | ||
asb.HasEndpoint("Finance.Billing"); | ||
|
||
bridgeConfiguration.AddTransport(msmq); | ||
bridgeConfiguration.AddTransport(asb); | ||
}) | ||
.Build() | ||
.RunAsync().ConfigureAwait(false); | ||
|
||
#endregion | ||
} | ||
|
||
public void RegisterPublishers() | ||
{ | ||
#region register-publisher | ||
|
||
var msmq = new BridgeTransport(new MsmqTransport()); | ||
msmq.HasEndpoint("Sales"); | ||
msmq.HasEndpoint("Finance.Billing"); | ||
|
||
var asb = new BridgeTransport(new AzureServiceBusTransport(connectionString)); | ||
asb.HasEndpoint("Shipping"); | ||
|
||
var invoicing = new BridgeEndpoint("Finance.Invoicing"); | ||
invoicing.RegisterPublisher(typeof(OrderBilled), "Finance.Billing"); | ||
invoicing.RegisterPublisher<OrderShipped>("Shipping"); | ||
invoicing.RegisterPublisher("Messages.OrderPlaced", "Sales"); | ||
|
||
asb.HasEndpoint(invoicing); | ||
|
||
#endregion | ||
|
||
#region register-publisher-legacy | ||
|
||
// Type.AssemblyQualifiedName Property value | ||
invoicing.RegisterPublisher("CreditApproved, CreditScoring.Messages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "Sales"); | ||
// Type.AssemblyQualifiedName Property but trimmed without Culture and PublicKeyToken as these are ignored by the message driven pub/sub feature | ||
invoicing.RegisterPublisher("CreditApproved, CreditScoring.Messages, Version=1.0.0.0", "Sales"); | ||
|
||
|
||
#endregion | ||
} | ||
|
||
public void AutoCreateQueues() | ||
{ | ||
#region auto-create-queues | ||
|
||
var msmq = new BridgeTransport(new MsmqTransport()) | ||
{ | ||
AutoCreateQueues = true | ||
}; | ||
|
||
var azureServiceBus = new BridgeTransport(new AzureServiceBusTransport(connectionString)) | ||
{ | ||
AutoCreateQueues = true | ||
}; | ||
|
||
#endregion | ||
} | ||
|
||
public void CustomConcurrency() | ||
{ | ||
#region custom-concurrency | ||
|
||
var msmq = new BridgeTransport(new MsmqTransport()) | ||
{ | ||
Concurrency = 10 | ||
}; | ||
|
||
var azureServiceBus = new BridgeTransport(new AzureServiceBusTransport(connectionString)) | ||
{ | ||
Concurrency = 5 | ||
}; | ||
|
||
#endregion | ||
} | ||
|
||
public void CustomErrorQueue() | ||
{ | ||
#region custom-error-queue | ||
|
||
var msmq = new BridgeTransport(new MsmqTransport()) | ||
{ | ||
ErrorQueue = "my-msmq-bridge-error-queue" | ||
}; | ||
|
||
var azureServiceBus = new BridgeTransport(new AzureServiceBusTransport(connectionString)) | ||
{ | ||
ErrorQueue = "my-asb-bridge-error-queue" | ||
}; | ||
|
||
#endregion | ||
} | ||
|
||
public void CustomTransportName() | ||
{ | ||
#region custom-transport-name | ||
|
||
var azureServiceBus1 = new BridgeTransport(new AzureServiceBusTransport(connectionStringNamepace1)) | ||
{ | ||
Name = "asb-namespace-1" | ||
}; | ||
|
||
var azureServiceBus2 = new BridgeTransport(new AzureServiceBusTransport(connectionStringNamepace2)) | ||
{ | ||
Name = "asb-namespace-2" | ||
}; | ||
|
||
#endregion | ||
} | ||
|
||
public void PlatformBridging() | ||
{ | ||
#region platform-bridging | ||
|
||
var transportWhereServiceControlIsInstalled = new BridgeTransport(new MsmqTransport()); | ||
|
||
transportWhereServiceControlIsInstalled.HasEndpoint("Particular.ServiceControl"); | ||
transportWhereServiceControlIsInstalled.HasEndpoint("Particular.Monitoring"); | ||
transportWhereServiceControlIsInstalled.HasEndpoint("error"); | ||
transportWhereServiceControlIsInstalled.HasEndpoint("audit"); | ||
|
||
#endregion | ||
} | ||
|
||
public void QueueName() | ||
{ | ||
#region custom-address | ||
|
||
var transport = new BridgeTransport(new MsmqTransport()); | ||
transport.HasEndpoint("Finance", "finance@machinename"); | ||
|
||
var endpoint = new BridgeEndpoint("Sales", "sales@another-machine"); | ||
transport.HasEndpoint(endpoint); | ||
|
||
#endregion | ||
} | ||
|
||
string connectionString = string.Empty; | ||
string connectionStringNamepace1 = string.Empty; | ||
string connectionStringNamepace2 = string.Empty; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
Snippets/Bridge/TransportBridge_1/ConfigureTransactionMode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using NServiceBus; | ||
|
||
class ConfigureTransactionMode | ||
{ | ||
void SetExplicitReceiveOnly() | ||
{ | ||
#region bridge-configuration-explicit-receive-only-mode | ||
|
||
var bridgeConfiguration = new BridgeConfiguration(); | ||
|
||
bridgeConfiguration.RunInReceiveOnlyTransactionMode(); | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Messages; | ||
|
||
public class OrderPlaced | ||
{ | ||
} | ||
|
||
public class OrderBilled | ||
{ | ||
} | ||
|
||
public class OrderShipped | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
`NServiceBus.MessagingBridge` is packaged as a host-agnostic library. It can be hosted in a console application, a Windows service, a Docker container, or any service that supports the Microsoft Generic Host, similar to how [endpoints are hosted](/nservicebus/hosting/selecting.md). |
1 change: 1 addition & 0 deletions
1
nservicebus/bridge/index_configuration_transportbridge_[1,2).partial.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
`NServiceBus.Transport.Bridge` is packaged as a host-agnostic library. It can be hosted in a console application, a Windows service, a Docker container, or any service that supports the Microsoft Generic Host, similar to how [endpoints are hosted](/nservicebus/hosting/selecting.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
When the messaging bridge encounters an error while transferring a message between transports it will move the message to the `bridge.error` queue, which is specific to the messaging bridge. An additional header `NServiceBus.MessagingBridge.FailedQ` is added to allow moving a message back to its originating queue, so the messaging bridge can pick them up again. | ||
|
1 change: 1 addition & 0 deletions
1
nservicebus/bridge/index_errors_transportbridge_[1,2).partial.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
When the messaging bridge encounters an error while transferring a message between transports it will move the message to the `bridge.error` queue, which is specific to the messaging bridge. An additional header `NServiceBus.Transport.Bridge.FailedQ` is added to allow moving a message back to its originating queue, so the messaging bridge can pick them up again. |
Oops, something went wrong.