0

I have the following Azure architecture:

IoTDevices ---> IoTHub ---> Function App

where:

  • IoTDevices: collect sensor data and send them to IoTHub
  • IoTHub: receives the data from devices and delivers those data to Function App (using Event Hub-compatible endpoint)
  • Function App: performs some processing on the received data

now in the Function App I have something like this:

public static void Run([IoTHubTrigger("messages/events", Connection = "EventHubConnection")]EventData message, TraceWriter log)
{
  string messageString = Encoding.UTF8.GetString(message.GetBytes());
  //do some processing with messageString as input
}

for several reasons, there are cases in which the processing can not be performed; I'd like to save the message SequenceNumber and defer the message so that later, when the processing become available again, I can re-receive the message from the IoTHub. So summarizing, the questions are:

  • how can I defer my message?
  • how can I re-receive/re-read the message given the SequenceNumber?
Giacomo Pirinoli
  • 548
  • 6
  • 17
  • 1
    An Event Hub doesn't do that natively. Either read from a Service Bus topic or queue, or write the failed messages to some other store, like a Service Bus topic or queue, or a database. – David Browne - Microsoft Jun 11 '20 at 16:16
  • ah, bad news for me; ok I'll probably go with database storage, but honestly I would have liked to simply defer the message and ask the EventHub to provide it later... – Giacomo Pirinoli Jun 12 '20 at 08:12

1 Answers1

1

https://learn.microsoft.com/en-us/azure/service-bus-messaging/message-deferral

Deferred messages remain in the main queue along with all other active messages (unlike dead-letter messages that live in a subqueue), but they can no longer be received using the regular Receive/ReceiveAsync functions. Deferred messages can be discovered via message browsing if an application loses track of them.

Neil
  • 11,059
  • 3
  • 31
  • 56
  • Hi @Neil, I've already read that part of the documentation but I am wondering how to move from ```EventData``` (what I have now in my code) to ```BrokeredMessage``` (what I need to perform deferral and re-receive) – Giacomo Pirinoli Jun 11 '20 at 16:15
  • 1
    `BrokeredMessage` is only for ServiceBus messages - IoT Hub messages are based on EventHub. So you would first need to route the IoT Hub messages into a Service Bus. – silent Jun 15 '20 at 10:11