I am trying to add an authorization feature on top of NSB using mutators and behaviors
- I have added an outgoing message mutator that adds the requesting users name to the message headers.
- I have added an incoming logical message behavior that takes this value from the message header and checks if the user is authorized for the action. I am using an incoming logical message behavior, because the message is decorated with an attribute that determines what roles are authorized for it.
- If the user is not authorized to perform the action, I will throw an UnauthorizedAccessException
When this type of exception is thrown, I would like to immediately fail the message and move it to the Error Q, not perform first and second level retries.
Looking through the documentation, it seems I should be able to handle this with a behavior… but I am not sure where/how. I read some posts that seemed to say the only way to short circuit it going to the error Q was by throwing a MessageDeserializationException… but since that is the first thing that happens to get a logical message, I am unsure if it’s possible.
What I have now works but the message is tried and throws an exception multiple times before going to the error Q. It rarely happens, but, when it does, I would like to skip the retries.
If anyone has any ideas, I’d like to hear it.