user2341923
user2341923

Reputation: 4727

Filter ServiceBusTrigger Messages based on Message Metadata

According to the documentation , Service Bus trigger provides several metadata properties. These properties can be used as part of binding expressions in other bindings or as parameters in the code. These properties are members of the Message class. Example:

[FunctionName("ServiceBusQueueTriggerCSharp")]                    
public static void Run(
    [ServiceBusTrigger("myqueue", Connection = "ServiceBusConnection")] 
    string myQueueItem,
    Int32 deliveryCount,
    DateTime enqueuedTimeUtc,
    string messageId,
    ILogger log)
{
    // Some code here
}

Is it possible for Service Bus Queues to automatically filter messages based metadata and accept only messages with e.g. certain ContentType or SessionId in a similar way as Correlation and SQL Filters in Topic Subscriptions?

Upvotes: 1

Views: 543

Answers (1)

Sean Feldman
Sean Feldman

Reputation: 25994

No, not possible as queues don’t support the filtering topics do. What you could do is use topics/subscriptions and auto-forward from the subscriptions to the queues so that the code that is designed to receive from the queues only could continue working as-is.

SessionId is an exception. Sessions are supported by queues but it’s more for processing and not filtering out messages.

Upvotes: 2

Related Questions