Skip to content

Commit

Permalink
snippetize the native pub sub article
Browse files Browse the repository at this point in the history
  • Loading branch information
yvesgoeleven committed Mar 17, 2021
1 parent ab7c785 commit 4b9116b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 16 deletions.
20 changes: 18 additions & 2 deletions Snippets/ASQ/ASQN_10/Usage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,27 @@ void RegisterPublisher(EndpointConfiguration configuration)
#region storage_account_routing_registered_publisher

var transportConfig = configuration.UseTransport<AzureStorageQueueTransport>();
transportConfig.DefaultAccountAlias("subscriber");
var routing = transportConfig
.ConnectionString("connectionString")
.AccountRouting();
var anotherAccount = routing.AddAccount("publisher", "anotherConnectionString");
anotherAccount.AddEndpoint("Publisher1", new[] { typeof(MyEvent) }, "optionalSubscriptionTableName");

#endregion
}

void RegisterSubscriber(EndpointConfiguration configuration)
{
#region storage_account_routing_registered_subscriber

var transportConfig = configuration.UseTransport<AzureStorageQueueTransport>();
transportConfig.DefaultAccountAlias("publisher");
var routing = transportConfig
.ConnectionString("anotherConnectionString")
.AccountRouting();
var anotherAccount = routing.AddAccount("PublisherAccountName", "connectionString");
anotherAccount.AddEndpoint("Publisher", new[] { typeof(MyEvent) });
var anotherAccount = routing.AddAccount("subscriber", "connectionString");
anotherAccount.AddEndpoint("Subscriber1");

#endregion
}
Expand Down
25 changes: 23 additions & 2 deletions Snippets/ASQ/ASQN_11/Usage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,29 @@ void RegisterPublisher(EndpointConfiguration configuration)
#region storage_account_routing_registered_publisher

var transport = new AzureStorageQueueTransport("connectionString");
var anotherAccount = transport.AccountRouting.AddAccount("PublisherAccountName", "anotherConnectionString");
anotherAccount.AddEndpoint("Publisher", new[] { typeof(MyEvent) });

transport.AccountRouting.DefaultAccountAlias = "subscriber";

var anotherAccount = transport.AccountRouting.AddAccount("publisher", "anotherConnectionString");
anotherAccount.AddEndpoint("Publisher1", new[] { typeof(MyEvent) }, "optionalSubscriptionTableName");

configuration.UseTransport(transport);

#endregion
#pragma warning restore CS0618
}

void RegisterSubscriber(EndpointConfiguration configuration)
{
#pragma warning disable CS0618
#region storage_account_routing_registered_subscriber

var transport = new AzureStorageQueueTransport("anotherConnectionString");

transport.AccountRouting.DefaultAccountAlias = "publisher";

var anotherAccount = transport.AccountRouting.AddAccount("subscriber", "connectionString");
anotherAccount.AddEndpoint("Subscriber1");

configuration.UseTransport(transport);

Expand Down
14 changes: 2 additions & 12 deletions transports/azure-storage-queues/native-publish-subscribe.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,8 @@ When the publisher dispatches the unicast operations, it queries for the interes

The following endpoint configuration is required to make sure `Subscriber1` can subscribe to `OrderAccepted` and `Publisher1` can send the message. The publisher configuration

```csharp
transport.AccountRouting.DefaultAccountAlias = "publisher";

var anotherAccount = transport.AccountRouting.AddAccount("subscriber", ...);
anotherAccount.AddEndpoint("Subscriber1");
```
snippet: storage_account_routing_registered_subscriber

the subscriber configuration

```csharp
transport.AccountRouting.DefaultAccountAlias = "subscriber";

var anotherAccount = transport.AccountRouting.AddAccount("publisher", ...);
anotherAccount.AddEndpoint("Publisher1", new[] { typeof(OrderAccepted) }, "optionalSubscriptionTableName");
```
snippet: storage_account_routing_registered_publisher

0 comments on commit 4b9116b

Please sign in to comment.