-
Notifications
You must be signed in to change notification settings - Fork 77
Handle exceptions during event mapping. #113
base: master
Are you sure you want to change the base?
Conversation
Avoid letting exceptions during event mapping cause multiple events to be lost. Also provide better logging.
As requested, a pull against master. |
doProcess(avroBuffer); | ||
listener.incomingRequest(event, avroBuffer, avroRecord); | ||
doProcess(avroBuffer); | ||
} catch (final RuntimeException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The listener call and the doProcess should go outside of the try-catch block, if we're guarding against mapping errors here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you look at the stack trace from #110, you will see it actually propagated up from fromRecord. I guess it wasn't strictly an error in the mapping logic, but rather the generic schema being employed. Either way, I think it is safer to include it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But to clarify, listener.incomingRequest & doProcess are both inside the try/catch block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I would consider the fromRecord to be part of the mapping (going from event to Avro) and doProcess(...) is part of handling the (then valid) avro record for enqueueing. Any error at that point would really be a bug and not a mapping error.
The listener is really just there for testing purposes (there's certain classes in the HTTP implementation that we cannot mock, so we use this path instead). Running Divolte normally shouldn't use it. If there is an exception in the listener, it's clearly a programming error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh geez. I misread your feedback... I read "inside" where you said "outside". Okay. I'll update the pull.
Neither are parting of the user configurable logic and should really execute without error.
Avoid letting exceptions during event mapping cause multiple events to
be lost. Also provide better logging.