0

enter image description here

I'm getting an error like this when i try to consume a topic using DAPR pub/sub. It looks like the message is consumed successfully, but an error is logged just before. Couldn't identify the root-cause. The issue happens only if I use declarative way of subscription. If we use the [Topic] annotation instead, no error is logged. I tried using different message brokers like rabbitMQ, redis, azure message bus. The case is same for all. Here's the configuration I use

pubsub.yml
# apiVersion: dapr.io/v1alpha1
# kind: Component
# metadata:
# name: pubsub
# spec:
# type: pubsub.redis
# version: v1
# metadata:
# - name: redisHost
# value: redis:6379
# - name: actorStateStore
# value: "true"
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: pubsub
spec:
type: pubsub.azure.servicebus.topics
version: v1
metadata:
  - name: connectionString
    value: 
Endpoint=sb://daprpocservicebus.servicebus.windows.net/;SharedAccessKeyName=RootManageShared AccessKey;SharedAccessKey=xxxxxxx

subscription.yml
apiVersion: dapr.io/v2alpha1
kind: Subscription
metadata:
name: pubsub
spec:
topic: weatherforecasttopic
routes:
default: /consume
pubsubname: pubsub
scopes:
  - daprpublisher
  - daprconsumer

And I'm publishing the values like this

await _daprClient.PublishEventAsync<WeatherForecast[]>(PubsubName, TopicNameOfWeatherForecast, forecast);

I'm stuck here. Any help much appreciated. Thanks in advance.

2
  • Can you please share the function body. How have you set the route for this function? I am also getting 404 . Is "/consume" actually your function name. Also where have you defined the scope "daprpublisher" Commented Oct 4, 2023 at 16:15
  • /consume is the route for the function in consumerservice. under scope you need to specify only the consumer service name. in my case 'daprconsumer'. will add the sample in the original answer. Commented Oct 5, 2023 at 7:14

1 Answer 1

0

Got the issue. I was getting the error since I have added both daprpublisher and daprconsumer services under the scopes. And the /consume endpoint was only available in the consumer.

But still getting a couple of 404 errors : GET /dapr/config : 404, GET /dapr/subscribe : 404 on application start-up. Need to investigate it further.

Update: Code sample

scopes:
  - daprconsumer

in controller

[HttpPost]
[Route("/consume")]
public ActionResult<bool> Consume([FromBody] WeatherForecast[] forecast)
Sign up to request clarification or add additional context in comments.

1 Comment

Did you find a solution to the 404 on the GET /dapr/config. This endpoint is for Actors (docs.dapr.io/developing-applications/building-blocks/actors/…) but we are not using this and still getting the same message.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.