1

Is there any traditional approach to consume Service Bus or EventHub messages from an ASPNET.CORE Web? Unless you start your own thread or long running task, I can't seem to find any information regarding this.

Mattias
  • 684
  • 3
  • 7
  • 16

1 Answers1

2

Both Azure Service Bus and Event Hubs consume messages by polling. Messages are not pushed. Therefore, just like you've said, you got to dedicated task or thread to host the polling code.

With Event Grid though, you could move to a push model where your webapp would react to events pushed to your application by Event Grid. Without knowing your specific scenario, this is a bit of a shot in the dark though. If your webapp is responding to messages that are events, then you could subscribe to either Azure specific events (emitted by Azure services) or custom events that your system would produce.

Note that at the moment Event Grid is in preview.

Sean Feldman
  • 23,443
  • 7
  • 55
  • 80
  • With Event Hubs you don't have to poll for new messages. It is done by [Host Processor](https://learn.microsoft.com/en-us/azure/event-hubs/event-hubs-dotnet-framework-api-overview) which takes a lot of work from developer. – cassandrad Oct 12 '17 at 16:57
  • Right, _you_ don't do it. The idea is that it's still polling initiated by the receiving party. – Sean Feldman Oct 12 '17 at 18:52
  • Event Hubs uses AMQP protocol and [official doc](https://learn.microsoft.com/en-us/azure/event-hubs/event-hubs-features) says that it does not poll. Why do you think it does? – cassandrad Oct 13 '17 at 08:06
  • That's correct. Even Hubs pushes messages to the consumer group. But the client side (your code) has to manage the offset/positioning. The Host Processor is storing it using Storage account. Your code is still responsible to request the messages, they are not pushed to the client side. That's what I ment. – Sean Feldman Oct 13 '17 at 15:21