Brian Hvarregaard
Brian Hvarregaard

Reputation: 4209

How do my Azure function selectively consume message from service bus?

I am building a integration module between multiple platforms, each needs to send and receive integration messages. I would like to have a simple service bus architecture, so instead of having 6 queues (3 systems, out/in for each). I would like to have a single "output" queue and a single "input" queue.

On each queue i would then put messages with specific data types (e.g. the content could be: "output.crm" meaning that this is the output for the crm system.). I have several Azure functions listening to this queue, but i want only some specific functions to actually process the message - the functions that know how to handle an "output.crm" message.

That is - im trying to implement a "selective consumer" type of pattern on this. Is this even possible with Azure functions?

Upvotes: 1

Views: 2007

Answers (3)

Roman Kiss
Roman Kiss

Reputation: 8265

Another option to the Service Bus Topic answered by Mikhail is to use an Azure Event Grid Pub/Sub model.

The AEG is an eventing model where a custom publisher (http client) sent the event message to the custom topic endpoint and the AEG notification manager will distribute it to all subscribers based on their subscriptions. There is an EventGridTrigger function as a AEG subscriber.

Note, that this model is a push model, so there is no need any listener for pull-up the message.

The AEG limits are:

  • 100 custom topics per Azure subscription
  • 500 event subscriptions per topic
  • 5000 events per second per topic

Upvotes: 1

Bikram
Bikram

Reputation: 523

What is the use of making separate functions listening to the same Queue?. As far as I know, it is not a good idea to listen the same queue by multiple listener.(There is a concept of queue partitioning but I am not that much familiar with it).

If you anyhow want to listen the same queue with multiple Servicebus listener then you can use the conditions and then abandon the message if conditions doesn't match. If you want this way of abandoning the message then I may help you out.

Note It is good to separate the responsibility by making the individual Azure function (Servicebus listener) to individual queue otherwise you may choose to use topic.

Upvotes: 0

Mikhail Shilkov
Mikhail Shilkov

Reputation: 35144

It looks like Service Bus Topic & Subscriptions could help you:

  1. Create a single Topic.
  2. Send messages to this Topic with data type in metadata.
  3. Create a Subscription per Azure Function. Add filters per subscription based on data type metadata value, see Topic filters and actions
  4. Configure your Functions to listen to a corresponding Subscription.

Upvotes: 3

Related Questions