#Aspire pub/sub with RabbitMq

1 messages · Page 1 of 1 (latest)

warm stirrup
#

I have several applications running in Aspire. I'm trying to add pub/sub between the apps using Dapr and RabbitMq.
RabbitMq is also hosted in Aspire.
In the components folder, I have a pubsub.yaml.
How do I configure the pubsub component with the live RabbitMq address from Aspire?
This can't work with static configuration, right?
Somehow I need to grab the endpoint from Aspire and configure that in Dapr.
Any pointers are appreciated.

pubsub.yaml

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: pubsub
spec:
  type: pubsub.rabbitMq
  version: v1
  metadata:
  - name: rabbitMqHost
    value: localhost:1234
  - name: password
    value: ""

AppHost code:

IResourceBuilder<ProjectResource> napkinsApi = builder.AddProject<Projects.Napkins_API>("napkins-api")
    .WithDaprSidecar(new DaprSidecarOptions
    {
        ResourcesPaths = ImmutableHashSet.Create("./components")
    })        
    .WithReference(rabbitMq);
winged chasm
#

From what I can tell, I don't think that is supported yet.

@livid bridge am I right on that?

livid bridge
winged chasm
#

So, the only option is to use the default in-memory pubsub component that comes with AddDaprPubSub() or BYO component which is outside of the lifecycle of Aspire?

livid bridge
# winged chasm So, the only option is to use the default in-memory pubsub component that comes ...

There are two "default" pubsub components when using AddDaprPubSub(). If you've initialized Dapr with its default Redis store, Aspire will use that one. If not (e.g. you've initialized Dapr with --slim), you'll get the in-memory component. In the latter case, pub-sub can only work within a single application (because it's in-memory for each side-car and, yes, that greatly limits its usefulness but that was the best I could do at the time). For the "ambient" state stores and pub-sub components, I had envisioned moving to pluggable components which would resolve the issues when running Dapr "slim", as well as have opportunities for new UX (like seeing what keys/values were set, or messages published) while the application ran. At the time, pluggable components were hampered by startup order issues. Aspire v9 now offers some freedom around that, so those ideas to be taken up again (by those with time/energy).

warm stirrup
#

Ok thanks guys for this. I've tried AddDaprPubSub. I see this error in the Dapr sidecar logs:

Fatal error from runtime: process component pubSub error: [INIT_COMPONENT_FAILURE]: initialization error occurred for pubSub (pubsub.redis/v1): init timeout for component pubSub (pubsub.redis/v1) exceeded after 5s

Does this look familiar? In Docker Desktop, I do see a running container dapr_redis.

livid bridge