Skip to content

Commit

Permalink
Merge branch 'main' into chore/deprecate-serilog-enricher-in-abstract…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
stijnmoreels authored Mar 9, 2025
2 parents 320fb92 + 482ff4f commit 9bf08d4
Show file tree
Hide file tree
Showing 121 changed files with 572 additions and 4,122 deletions.
44 changes: 22 additions & 22 deletions docs/preview/02-Features/02-message-handling/01-service-bus.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Once the message handler is created, you can very easily register it:
```csharp
using Microsoft.Extensions.DependencyInjection;

public class Startup
public class Program
{
public void ConfigureServices(IServiceCollection services)
{
Expand Down Expand Up @@ -113,12 +113,15 @@ We would like that this handler only processed the message when the context cont
```csharp
using Microsoft.Extensions.DependencyInjection;

public class Startup
public class Program
{
public void ConfigureServices(IServiceCollection services)
{
services.AddServiceBusTopicMessagePump(...)
.WithServiceBusMessageHandler<OrderMessageHandler, Order>(context => context.Properties["MessageType"].ToString() == "Order");
.WithServiceBusMessageHandler<OrderMessageHandler, Order>(options =>
{
options.AddMessageContextFilter(context => context.Properties["MessageType"].ToString() == "Order"));
});
}
}
```
Expand Down Expand Up @@ -156,20 +159,22 @@ The registration of these message body serializers can be done just as easily as
```csharp
using Microsoft.Extensions.DependencyInjection;

public class Startup
public class Program
{
public void ConfigureServices(IServiceCollection services)
{
// Register the message body serializer in the dependency container where the dependent services will be injected.
services.AddServiceBusTopicMessagePump(...)
.WitServiceBusMessageHandler<OrderBatchMessageHandler>(..., messageBodySerializer: new OrderBatchMessageBodySerializer());

// Register the message body serializer in the dependency container where the dependent services are manually injected.
services.AddServiceBusTopicMessagePump(...)
.WithServiceBusMessageHandler(..., messageBodySerializerImplementationFactory: serviceProvider =>
.WitServiceBusMessageHandler<OrderBatchMessageHandler>(options =>
{
var logger = serviceProvider.GetService<ILogger<OrderBatchMessageHandler>>();
return new OrderBatchMessageHandler(logger);
// Option #1
options.AddMessageBodySerializer(new OrderBatchMessageBodySerializer());

// Option #2
options.AddMessageBodySerializer(serviceProvider =>
{
var logger = serviceProvider.GetService<ILogger<OrderBatchMessageHandler>>();
return new OrderBatchMessageHandler(logger);
});
});
}
}
Expand Down Expand Up @@ -209,12 +214,15 @@ public class OrderMessageHandler : IAzureServiceBusMessageHandler<Order>
using Microsoft.Extensions.DependencyInjection;

// Message handler registration
public class Startup
public class Program
{
public void ConfigureServices(IServiceCollection services)
{
services.AddServiceBusTopicMessagePump(...)
.WithServiceMessageHandler<OrderMessageHandler, Order>((Order order) => order.Type == Department.Sales);
.WithServiceMessageHandler<OrderMessageHandler, Order>(options =>
{
options.AddMessageBodyFilter((Order order) => order.Type == Department.Sales));
});
}
}
```
Expand Down Expand Up @@ -435,10 +443,6 @@ public class Startup
// this job instance in a multi-instance deployment (default: guid).
options.JobId = Guid.NewGuid().ToString();

// The format of the message correlation used when receiving Azure Service Bus messages.
// (default: W3C).
options.Routing.Correlation.Format = MessageCorrelationFormat.Hierarchical;

// The name of the operation used when tracking the request telemetry.
// (default: Process)
options.Routing.Correlation.OperationName = "Order";
Expand Down Expand Up @@ -491,10 +495,6 @@ public class Startup
// this job instance in a multi-instance deployment (default: guid).
options.JobId = Guid.NewGuid().ToString();

// The format of the message correlation used when receiving Azure Service Bus messages.
// (default: W3C).
options.Routing.Correlation.Format = MessageCorrelationFormat.Hierarchical;

// The name of the operation used when tracking the request telemetry.
// (default: Process)
options.Routing.Correlation.OperationName = "Order";
Expand Down

This file was deleted.

Loading

0 comments on commit 9bf08d4

Please sign in to comment.