0

We have an Azuer EventHub which receives messages from different sources.

For some unavoidable reasons, we receive invalid JSON payload from time to time which causes deserialisation fail in subscribers of EventHub.

Is there a way we can add restrictions to the EventHub to receive only valid JSON payloads and reject the invalid ones? So that the publishers get to know that message was rejected and they need to fix them?

I know we can treat the payload as a plain string and try to parse them in our subscribers but then we need to inform the sources about it and I see this as the last option.

Mori
  • 2,484
  • 5
  • 28
  • 45
  • related to https://stackoverflow.com/questions/54789404/is-there-any-way-to-validate-events-payload-schema-while-using-azure-event-hub-a – Peter Bons Feb 28 '19 at 11:46

1 Answers1

1

The Event Hub does not look into the data. For it, the payload is just binary. So no, there is no built-in way to achieve this.

You might be able to use the Routing feature which is built into IoT Hub. This one can route messages based on JSON body content. You still would not be able to reject the messages but you could for instance route the messages into some "invalid message" queue - or just don't route them anywhere.

silent
  • 14,494
  • 4
  • 46
  • 86