DAPR / Aspire Pubsub не загружает компонент yamlC#

Место общения программистов C#
Ответить Пред. темаСлед. тема
Anonymous
 DAPR / Aspire Pubsub не загружает компонент yaml

Сообщение Anonymous »

Я пытаюсь настроить проект с Aspire и DAPR. Pubsub должен поступать из файла компонентов DAPR YAML. < /P>
Я подключил DaprClient < /code> и создал конечную точку на Frontend и API, чтобы получить HHTP Post /Pullish. Когда я называю эту конечную точку, я получаю следующее исключение: < /p>

Код: Выделить всё

curl --request POST 'http://localhost:5133/publish'< /code> < /p>

dapr.daprexception: Отказ публикации не удастся: конечная точка DAPR
указал на сбой. Смотрите Innerexception для деталей.  --->
grpc.core.rpcexception: statuscode = "Invalidargument",
detail = "pubsub pubsub не найден") at
dapr.client.daprclientgrpc.makepublishrequest(string cubsubnam2 metadata, String dataContentType, CancellationToken cancellationToken)    --- End of inner exception stack trace ---    at Dapr.Client.DaprClientGrpc.MakePublishRequest(String pubsubName, String topicName, ByteString content, Dictionary< /code> 2 метаданные, строка
dataContenttype, CancellationToken CancellationToken) AT
Program.  c.  B__0_2> D.movenext () в
c:lomusers\myusername\source\reposepreapps\ in
adrybramername\morce\reposepreapps\ /> --- Конец стека трассировки из предыдущего местоположения --- at microsoft.aspnetcore.http.requestdelegatefactory.executetaskresult [t] (задача  контекст) at
microsoft.aspnetcore.diagnostics.developerexceptionpagemiddlewareimpl.invoke(httpcontext
context) < /p>
Заголовки
Accept:  /< /em>
host: localhost: 5133
user-agtent: 5133
 /< /em>
curl/8.13.0 

Ставка моего проекта следующая: 
AspireApp
├───AspireApps.ApiService
│   ├───bin
│   │   └───...
│   ├───obj
│   │   └───...
│   └───Properties
├───AspireApps.AppHost
│   ├───bin
│   │   └───...
│   ├───obj
│   │   └───...
│   └───Properties
├───AspireApps.ServiceDefaults
│   ├───bin
│   │   └───...
│   └───obj
│       └───...
├───AspireApps.Web
│   ├───bin
│   │   └───...
│   ├───Components
│   │   ├───Layout
│   │   └───Pages
│   ├───obj
│   │   └───Debug
│   │       └───net9.0
│   │           ├───...
│   ├───Properties
│   └───wwwroot
│       └───lib
│           └───...
└───dapr
└───components
└─── pubsub.yaml
Apphost.cs

Код: Выделить всё

using CommunityToolkit.Aspire.Hosting.Dapr;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

var builder = DistributedApplication.CreateBuilder(args);

var cache = builder.AddRedis("cache").WithDbGate();

var daprState = builder.AddDaprStateStore("statestore");

DaprSidecarOptions sideCarOptions = new DaprSidecarOptions
{
EnableAppHealthCheck = true,
AppHealthCheckPath = "/health",
};

IResourceBuilder? rabbitmq = null;
var pubSubType = "pubsub.azure.servicebus";

if (builder.Environment.IsDevelopment())
{
var username = builder.AddParameterFromConfiguration("rabbitmq-username", "guest", true);
var password = builder.AddParameterFromConfiguration("rabbitmq-password", "guest", true);
rabbitmq = builder.AddRabbitMQ("rabbitmq", username, password)
.WithManagementPlugin();

pubSubType = "pubsub.rabbitmq";
}
var daprPubSubBuilder = builder.AddDaprComponent("pubsub", pubSubType, new DaprComponentOptions
{
LocalPath = Path.Combine("..", "dapr", "components")
});

var apiService = builder.AddProject
("apiservice")
.WithHttpHealthCheck("/health")
.WithReference(cache)
.WaitFor(cache)
.WithDaprSidecar(sideCarOptions)
.WithReference(daprState)
.WithReference(daprPubSubBuilder);

// Wait for RabbitMQ in development
if (rabbitmq != null)
{
apiService = apiService.WithReference(rabbitmq).WaitFor(rabbitmq);
}

var webFrontend = builder.AddProject("webfrontend")
.WithExternalHttpEndpoints()
.WithHttpHealthCheck("/health")
.WithReference(cache)
.WaitFor(cache)
.WithDaprSidecar(sideCarOptions)
.WithReference(daprState)
.WithReference(daprPubSubBuilder)
.WithReference(apiService)
.WaitFor(apiService);

// Wait for RabbitMQ in development
if (rabbitmq != null)
{
webFrontend = webFrontend.WithReference(rabbitmq).WaitFor(rabbitmq);
}

//Inject Dapr client for DI / service-to-service calls
builder.Services.AddDaprClient();

builder.Build().Run();
pubsub.yaml (я попробовал это с и без подсказок )

Код: Выделить всё

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: pubsub
spec:
type: pubsub.rabbitmq
version: v1
metadata:
- name: host
value: amqp://guest:guest@rabbitmq:5672
- name: durable
value: "true"
- name: deletedWhenUnused
value: "false"
- name: autoAck
value: "false"
- name: deliveryMode
value: "2"
- name: requeueInFailure
value: "true"
scopes:
- webfrontend
- apiservice
Когда приложение запускается, приборная панель Aspire освещает зеленый.

Код: Выделить всё

level=warning msg="A non-YAML resiliency file components was detected, it will not be loaded" app_id=apiservice instance=mymachinename scope=dapr.runtime type=log ver=1.15.10
WARNING: no application command found. Starting Dapr with id
apiservice. HTTP Port: 59008. gRPC Port: 59006
time="2025-09-05T12:49:39.777069+01:00" level=info msg="Starting Dapr
Runtime -- version 1.15.10 -- commit
0f5f0b75a944d56c0b78b5d8db31c268a1f21d90" app_id=apiservice
instance=mymachinename scope=dapr.runtime type=log ver=1.15.10
time="2025-09-05T12:49:39.777069+01:00" level=info msg="Log level set
to: info" app_id=apiservice instance=mymachinename scope=dapr.runtime
type=log ver=1.15.10 time="2025-09-05T12:49:39.7776962+01:00"
level=warning msg="mTLS is disabled. Skipping certificate request and
tls validation" app_id=apiservice instance=mymachinename
scope=dapr.runtime.security type=log ver=1.15.10
time="2025-09-05T12:49:39.7841769+01:00" level=info msg="Enabled
features: SchedulerReminders" app_id=apiservice
instance=mymachinename scope=dapr.runtime type=log ver=1.15.10
time="2025-09-05T12:49:39.7846949+01:00" level=info msg="metric spec:
{"enabled":true}" app_id=apiservice instance=mymachinename
scope=dapr.runtime.diagnostics type=log ver=1.15.10
time="2025-09-05T12:49:39.7846949+01:00" level=info msg="Using default
latency distribution buckets: [1 2 3 4 5 6 8 10 13 16 20 25 30 40 50
65 80 100 130 160 200 250 300 400 500 650 800 1000 2000 5000 10000
20000 50000 100000]" app_id=apiservice instance=mymachinename
scope=dapr.runtime.diagnostics type=log ver=1.15.10
time="2025-09-05T12:49:39.7846949+01:00" level=warning msg="The
default value for 'spec.metric.http.increasedCardinality' will change
to 'false' in Dapr 1.15 or later" app_id=apiservice
instance=mymachinename scope=dapr.runtime.diagnostics type=log
ver=1.15.10 time="2025-09-05T12:49:39.7865149+01:00" level=warning
msg="A non-YAML resiliency file components was detected, it will not
be loaded" app_id=apiservice instance=mymachinename
scope=dapr.runtime type=log ver=1.15.10
time="2025-09-05T12:49:39.7865727+01:00" level=info msg="standalone
mode configured" app_id=apiservice instance=mymachinename
scope=dapr.runtime type=log ver=1.15.10
time="2025-09-05T12:49:39.7865727+01:00" level=info msg="app id:
apiservice" app_id=apiservice instance=mymachinename
scope=dapr.runtime type=log ver=1.15.10
time="2025-09-05T12:49:39.7876633+01:00" level=info msg="Dapr trace
sampler initialized:
ParentBased{root:AlwaysOnSampler,remoteParentSampled:AlwaysOnSampler,remoteParentNotSampled:AlwaysOffSampler,localParentSampled:AlwaysOnSampler,localParentNotSampled:AlwaysOffSampler}"
app_id=apiservice instance=mymachinename scope=dapr.runtime type=log
ver=1.15.10 time="2025-09-05T12:49:39.7882915+01:00" level=info
msg="metrics server started on 0.0.0.0:59010/" app_id=apiservice
instance=mymachinename scope=dapr.runtime type=log ver=1.15.10
time="2025-09-05T12:49:39.8285502+01:00" level=info msg="local service
entry announced: apiservice -> 10.114.236.36:56419" app_id=apiservice
component="nr (mdns/v1)" instance=mymachinename scope=dapr.contrib
type=log ver=1.15.10 time="2025-09-05T12:49:39.8290925+01:00"
level=info msg="Initialized name resolution to mdns" app_id=apiservice
instance=mymachinename scope=dapr.runtime type=log ver=1.15.10
time="2025-09-05T12:49:39.8291985+01:00" level=info msg="Loading
components…" app_id=apiservice instance=mymachinename
scope=dapr.runtime type=log ver=1.15.10
time="2025-09-05T12:49:39.8313238+01:00" level=info msg="Waiting for
all outstanding components to be processed…" app_id=apiservice
instance=mymachinename scope=dapr.runtime type=log ver=1.15.10
time="2025-09-05T12:49:39.8319286+01:00" level=info msg="Component
loaded: statestore (state.in-memory/v1)" app_id=apiservice
instance=mymachinename scope=dapr.runtime.processor type=log
ver=1.15.10 time="2025-09-05T12:49:39.8319286+01:00" level=info
msg="All outstanding components processed" app_id=apiservice
instance=mymachinename scope=dapr.runtime type=log ver=1.15.10
time="2025-09-05T12:49:39.8319286+01:00" level=info msg="Loading
endpoints…" app_id=apiservice instance=mymachinename
scope=dapr.runtime type=log ver=1.15.10
time="2025-09-05T12:49:39.8330666+01:00" level=info msg="Waiting for
all outstanding http endpoints to be processed…" app_id=apiservice
instance=mymachinename scope=dapr.runtime type=log ver=1.15.10
time="2025-09-05T12:49:39.8332717+01:00" level=info msg="All
outstanding http endpoints processed" app_id=apiservice
instance=mymachinename scope=dapr.runtime type=log ver=1.15.10
time="2025-09-05T12:49:39.8332717+01:00" level=info msg="Loading
Declarative Subscriptions…" app_id=apiservice instance=mymachinename
scope=dapr.runtime type=log ver=1.15.10
time="2025-09-05T12:49:39.8365689+01:00" level=info msg="gRPC server
listening on TCP address: :59006" app_id=apiservice
instance=mymachinename scope=dapr.runtime.grpc.api type=log
ver=1.15.10 time="2025-09-05T12:49:39.8365689+01:00" level=info
msg="Enabled gRPC tracing middleware" app_id=apiservice
instance=mymachinename scope=dapr.runtime.grpc.api type=log
ver=1.15.10 time="2025-09-05T12:49:39.8365689+01:00" level=info
msg="Enabled gRPC metrics middleware" app_id=apiservice
instance=mymachinename scope=dapr.runtime.grpc.api type=log
ver=1.15.10 time="2025-09-05T12:49:39.8365689+01:00" level=info
msg="Registering workflow engine for gRPC endpoint: [::]:59006"
app_id=apiservice instance=mymachinename scope=dapr.runtime.grpc.api
type=log ver=1.15.10 time="2025-09-05T12:49:39.8365689+01:00"
level=info msg="API gRPC server is running on port 59006"
app_id=apiservice instance=mymachinename scope=dapr.runtime type=log
ver=1.15.10 time="2025-09-05T12:49:39.8365689+01:00" level=warning
msg="The default value for 'spec.metric.http.increasedCardinality'
will change to 'false' in Dapr 1.15 or later" app_id=apiservice
instance=mymachinename scope=dapr.runtime.http type=log ver=1.15.10
time="2025-09-05T12:49:39.8377913+01:00" level=info msg="Enabled max
body size HTTP middleware with size 4194304 bytes" app_id=apiservice
instance=mymachinename scope=dapr.runtime.http type=log ver=1.15.10
time="2025-09-05T12:49:39.8378438+01:00" level=info msg="Enabled
tracing HTTP middleware" app_id=apiservice instance=mymachinename
scope=dapr.runtime.http type=log ver=1.15.10
time="2025-09-05T12:49:39.8378438+01:00" level=info msg="Enabled
metrics HTTP middleware" app_id=apiservice instance=mymachinename
scope=dapr.runtime.http type=log ver=1.15.10
time="2025-09-05T12:49:39.8384367+01:00" level=info msg="HTTP server
listening on TCP address: :59008" app_id=apiservice
instance=mymachinename scope=dapr.runtime.http type=log ver=1.15.10
time="2025-09-05T12:49:39.8389811+01:00" level=info msg="HTTP server
is running on port 59008" app_id=apiservice instance=mymachinename
scope=dapr.runtime type=log ver=1.15.10
time="2025-09-05T12:49:39.8389811+01:00" level=info msg="The request
body size parameter is: 4194304 bytes" app_id=apiservice
instance=mymachinename scope=dapr.runtime type=log ver=1.15.10
time="2025-09-05T12:49:39.8389811+01:00" level=info msg="gRPC server
listening on TCP address: :56419" app_id=apiservice
instance=mymachinename scope=dapr.runtime.grpc.internal type=log
ver=1.15.10 time="2025-09-05T12:49:39.8389811+01:00" level=info
msg="Enabled gRPC tracing middleware" app_id=apiservice
instance=mymachinename scope=dapr.runtime.grpc.internal type=log
ver=1.15.10 time="2025-09-05T12:49:39.8389811+01:00" level=info
msg="Enabled gRPC metrics middleware" app_id=apiservice
instance=mymachinename scope=dapr.runtime.grpc.internal type=log
ver=1.15.10 time="2025-09-05T12:49:39.8389811+01:00" level=info
msg="Internal gRPC server is running on :56419" app_id=apiservice
instance=mymachinename scope=dapr.runtime type=log ver=1.15.10
time="2025-09-05T12:49:39.8416276+01:00" level=info msg="actors: state
store is not configured - this is okay for clients but services with
hosted actors will fail to initialize!" app_id=apiservice
instance=mymachinename scope=dapr.runtime type=log ver=1.15.10
time="2025-09-05T12:49:39.8417428+01:00" level=info msg="Actor state
store not configured - actor hosting disabled, but invocation enabled"
app_id=apiservice instance=mymachinename scope=dapr.runtime.actor
type=log ver=1.15.10 time="2025-09-05T12:49:39.8422631+01:00"
level=info msg="application protocol: http. waiting on port 5506.
This will block until the app is listening on that port."
app_id=apiservice instance=mymachinename scope=dapr.runtime type=log
ver=1.15.10 time="2025-09-05T12:49:39.8425038+01:00" level=info
msg="Actor runtime started" app_id=apiservice instance=mymachinename
scope=dapr.runtime.actor type=log ver=1.15.10
time="2025-09-05T12:49:39.8425038+01:00" level=info msg="worker
started with backend dapr.actors/v1" app_id=apiservice
instance=mymachinename scope=dapr.wfengine.durabletask.backend
type=log ver=1.15.10 time="2025-09-05T12:49:39.8425038+01:00"
level=warning msg="Graceful shutdown timeout is infinite, will wait
indefinitely to shutdown" app_id=apiservice instance=mymachinename
scope=dapr.runtime.actor type=log ver=1.15.10
time="2025-09-05T12:49:39.8425038+01:00" level=info msg="Workflow
engine started" app_id=apiservice instance=mymachinename
scope=dapr.runtime.wfengine type=log ver=1.15.10
time="2025-09-05T12:49:39.8430499+01:00" level=info msg="Reporting
actor types: []" app_id=apiservice instance=mymachinename
scope=dapr.runtime.actors.placement type=log ver=1.15.10
time="2025-09-05T12:49:39.8431251+01:00" level=info msg="Connected to
placement localhost:6050" app_id=apiservice instance=mymachinename
scope=dapr.runtime.actors.placement.client.connector.static type=log
ver=1.15.10 time="2025-09-05T12:49:39.8448018+01:00" level=info
msg="application discovered on port 5506" app_id=apiservice
instance=mymachinename scope=dapr.runtime type=log ver=1.15.10
time="2025-09-05T12:49:39.8448018+01:00" level=info msg="App health
probes starting" app_id=apiservice instance=mymachinename
scope=dapr.apphealth type=log ver=1.15.10
time="2025-09-05T12:49:39.8448018+01:00" level=info msg="dapr
initialized. Status: Running. Init Elapsed 58ms" app_id=apiservice
instance=mymachinename scope=dapr.runtime type=log ver=1.15.10
time="2025-09-05T12:49:39.8510653+01:00" level=info msg="Connected to
placement localhost:6050" app_id=apiservice instance=mymachinename
scope=dapr.runtime.actors.placement.client type=log ver=1.15.10
time="2025-09-05T12:49:39.8581726+01:00" level=info msg="Connected and
received scheduler hosts addresses: [localhost:6060]"
app_id=apiservice instance=mymachinename
scope=dapr.runtime.scheduler.watchhosts type=log ver=1.15.10
time="2025-09-05T12:49:39.8587389+01:00" level=info msg="Scheduler
client initialized for address: localhost:6060" app_id=apiservice
instance=mymachinename scope=dapr.runtime.scheduler.clients type=log
ver=1.15.10 time="2025-09-05T12:49:39.8587389+01:00" level=info
msg="Scheduler clients initialized" app_id=apiservice
instance=mymachinename scope=dapr.runtime.scheduler.clients type=log
ver=1.15.10 time="2025-09-05T12:49:39.8982609+01:00" level=info
msg="Placement tables updated, version: 0" app_id=apiservice
instance=mymachinename scope=dapr.runtime.actors.placement type=log
ver=1.15.10 You're up and running! Dapr logs will appear here.

time="2025-09-05T12:50:04.85723+01:00" level=info msg="App entered
healthy status" app_id=apiservice instance=mymachinename
scope=dapr.apphealth type=log ver=1.15.10
time="2025-09-05T12:50:04.8631114+01:00" level=info msg="Application
configuration loaded" app_id=apiservice instance=mymachinename
scope=dapr.runtime type=log ver=1.15.10
time="2025-09-05T12:50:04.8631114+01:00" level=info msg="Registering
hosted actors: []" app_id=apiservice instance=mymachinename
scope=dapr.runtime.actor type=log ver=1.15.10
time="2025-09-05T12:50:04.8631114+01:00" level=info msg="Updating
actor types: []" app_id=apiservice instance=mymachinename
scope=dapr.runtime.actors.placement type=log ver=1.15.10
time="2025-09-05T12:50:04.8636744+01:00" level=info msg="Scheduler
stream connected for [JOB_TARGET_TYPE_JOB]" app_id=apiservice
instance=mymachinename scope=dapr.runtime.scheduler.cluster type=log
ver=1.15.10

Running command dapr list

APP ID HTTP PORT GRPC PORT APP PORT COMMAND AGE CREATED
DAPRD PID CLI PID APP PID webfrontend 59007 59004 5133 3m 2025-09-05 12:49.39 37448 29752 0
apiservice 63121 63120 5506 1m 2025-09-05 12:51.44 25296 38188 0

Querying the metadata of the sidecar shows that the component is not loaded:
curl http://localhost:59007/v1.0/metadata< /code> < /p>


"ID":"Webfrontend","runtimeversion""""" год.15.10","enabledfeatures" В.С.SchedulerReminders"цин "Components" В :name"! y "," версия ":" v1 "," Возможности ": [" etag "," транзакция "," ttl "," delete_with_prefix "," actor "]}]," расширен ": {" clipid ":" 29752 "," daprruntimeversion ":" 1. 15.10 "}," AppConnectionProperties ": {" порт ": 5133," протокол ":" http "," ChannelAddress ":" LocalHost "," Health ": {" HealthCheckpath ":"/Health "," HealthProbeint erval ":" 5s "," healthProbeTimeout ":" 500 мс "," HealthThreshold ": 3}}," Actorruntime ": {" runtimeStatus ":" running "," hostready ": true," Placeement ":" Placement:
Connected "}," Scheduler ": {" Connected_Addresses ": [" LocalHost: 6060 "]}} < /p>
< /blockquote>

Подробнее здесь: https://stackoverflow.com/questions/797 ... onent-yaml
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «C#»