Using multiple PubSub in DAPR with Aspire

I have a .net 8 Aspire solution, in which i configure various micro services and attach a DAPR sidecar to each of them, like so:

// Aspire configuration

var builder = DistributedApplication.CreateBuilder(args);

builder.AddDapr();

var resourcesPath = new List<string> { builder.Configuration["Dapr:ComponentsPath"]! }.ToImmutableHashSet();

var microServicesConfig = builder.Configuration.GetSection("MicroServices").Get<MicroServiceConfig[]>()!;
foreach (var config in microServicesConfig)
{
    if (!config.IsEnabled) continue;

    if (string.IsNullOrWhiteSpace(config.ProjectPath)) continue;

    builder.AddProject(config.ContainerName, config.ProjectPath!, "http")
        .WithDaprSidecar(new DaprSidecarOptions
            {
                AppId = config.ContainerName,
                Config = configFilePath,
                ResourcesPaths = resourcesPath,
                MetricsPort = config.MetricsPort,
                DaprHttpPort = config.DaprHttpPort,
                DaprGrpcPort = config.DaprGrpcPort,
                AppPort = config.AppPort,
            });
}

var app = builder.Build();

await app.RunAsync();

my appsettings.json looks like this:

{
  "Dapr": {
    "ComponentsPath": ".\Dapr\Components",
    "ConfigPath": ".\Dapr\config.yaml"
  }
  "MicroServices": [
  {
    "ContainerName": "user-api-service",
    "MetricsPort": 9092,
    "DaprHttpPort": 3502,
    "DaprGrpcPort": 50002,
    "AppPort": 7074,
    "HttpEndpoint": 5002,
    "ContainerPort": 8080,
    "ProjectPath": "../../user.apiService/user.apiService.csproj",
    "IsEnabled": true
  },
  {
    "ContainerName": "tenant-api-service",
    "MetricsPort": 9090,
    "DaprHttpPort": 3500,
    "DaprGrpcPort": 50000,
    "AppPort": 7238,
    "HttpEndpoint": 5004,
    "ContainerPort": 8080,
    "ProjectPath": "../../tenant.apiService/tenant.apiService.csproj",
    "IsEnabled": true
  },
  {
    "ContainerName": "sender-api-service",
    "MetricsPort": 9091,
    "DaprHttpPort": 3501,
    "DaprGrpcPort": 50001,
    "AppPort": 7070,
    "HttpEndpoint": 5001,
    "ContainerPort": 8080,
    "ProjectPath": "../../sender.apiService/sender.apiService.csproj",
    "IsEnabled": true
  }
}

This is my config.yaml:

apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
  name: daprConfig
  namespace: default
spec:
  tracing:
    samplingRate: "1"
    zipkin:
      endpointAddress: http://localhost:9411/api/v2/spans

This is the state store:

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: StateStore
spec:
  type: state.redis
  version: v1
  metadata:
  - name: redisHost
    value: localhost:6379
  - name: redisPassword
    value: ""
  - name: actorStateStore
    value: "true"

Last, these are the 2 pubsub components i want to use:

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: UserPubSub
  namespace: default
spec:
  type: pubsub.redis
  version: v1
  metadata:
  - name: redisHost
    value: localhost:6379
  - name: redisPassword
    value: ""
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: TenantPubSub
  namespace: default
spec:
  type: pubsub.redis
  version: v1
  metadata:
  - name: redisHost
    value: localhost:6379
  - name: redisPassword
    value: ""

As you can see, i have 3 projects: user, tenant and sender.

In the Aspire configuration, I am configuring all the pubsub components on all the micro services. I tried adding only the needed ones to each microservice: user only needs UserPubSub and the StateStore, same for tenant but with TenantPubSub instead of UserPubSub, and sender needs all 3 UserPubSub, TenantPubSub and the StateStore.

The result is always the same: I send a request expecting only user to receive it, but also tenant receives it.

The flow is this:

  1. I call an api on sender
  2. sender executes some logic and then returns the result to the client
  3. The result from step 2 is also forwarded to user or tenant, based on which logic was executed – in this case only to user

I have an endpoint on sender to simulate the flow:

builder.MapGet
    ("send/{pubsub}/create/{message}", async (string pubsub, string message, [FromServices] DaprClient daprClient, CancellationToken ct) =>
    {
        await daprClient.PublishEventAsync(pubsub, "create", message, ct);
        return Results.Ok();
    });

The user micro service is subscribed to:

builder.MapPost
    ("user/create", [Topic("UserPubSub", "create")] async ([FromBody] string message) =>
    {
        if (!string.IsNullOrWhiteSpace(message)) return Results.Ok();
        return Results.BadRequest();
    });

While the tenant microservice is subscribed to:

builder.MapPost
    ("tenant/create", [Topic("TenantPubSub", "create")] async ([FromBody] string message) =>
    {
        if (!string.IsNullOrWhiteSpace(message)) return Results.Ok();
        return Results.BadRequest();
    });

I call the sender API with this request GET http://localhost:7238/send/UserPubSub/create/Hello, so i am expecting only the user micro service to receive the message.

Somehow, also the tenant microservice is receiving it.

What am i missing?

If you need more details, I’ll be more than happy to enrich my question.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật