Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom metadata not provided to subscriber #1438

Open
richaswr opened this issue Jan 7, 2025 · 0 comments
Open

Custom metadata not provided to subscriber #1438

richaswr opened this issue Jan 7, 2025 · 0 comments
Labels
kind/bug Something isn't working

Comments

@richaswr
Copy link

richaswr commented Jan 7, 2025

Expected Behavior

Custom metadata properties set for a message published using DaprClient are made available to subscribers of this message.

Actual Behavior

Custom metadata properties are not available from Http headers or otherwise.

Steps to Reproduce the Problem

  • My dapr components are set up with Azure Container Apps, so there may be a limitation I am unaware of
  • I am using Asp.net for this for the most part, with DaprClient used to publish and TopicAttribute to define subscriptions within the controllers.
  • Due to some complexity with our application, I use Terraform to actually set up the subscriptions, with disableEntityManagement set to true to prevent Dapr setting up the subscriptions itself (perhaps I've missed something key here)

With Azure Service Bus Topics, I can set custom metadata properties using the DaprClient on publish:

var metadata = new Dictionary<string, string>
{
    {"cloudevent.type", eventType},
    {"eventName", eventName}
};

//@event refers to a class object
await daprClient.PublishEventAsync("pubsubName", "topicName", @event, metadata, ct);

I have a controller with endpoints decorated using the TopicAttribute, like below:

[HttpPost]
[Route("handle")]
[Topic("pubsubName", "topicName")]
public async Task<Result> HandleMessageAsyncJsonDocument @event, [FromHeader(Name="eventName")]string eventName)
{
    logger.LogInformation($"EventName: {eventName}");
    var context = contextAccessor.HttpContext;
    if (context is null)
    {
        logger.LogInformation($"Could not retrieve HttpContext");
    }
    else
    {
        foreach(var header in context.Request.Headers)
        {
            logger.LogInformation($"Header: {header.Key} - {header.Value}");
        }
    }

    return Result.Error();
}

However, whether it's by the FromHeader property or the HttpContext itself, these custom properties, I believe referred to as ApplicationProperties in Azure Service Bus, are not made available.

Release Note

RELEASE NOTE:

@richaswr richaswr added the kind/bug Something isn't working label Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant