I propose to implement the following post and pre handlers in the library in which the library user would be able to handle calls at his discretion:
public enum MessageProcessResult {
Ask,
Reject,
Nack,
}
/**
* @summary
* Raw payload from message broker
*/
interface IDeliveredMessage {}
/**
* @summary
* Common post-pre handlers lib configuration
*/
interface IQueueHandlersConfig {
/**
* @summary
* The handler is started last in the chain, and you can change the result of the previous MessageProcessResult in it
*/
afterExecute: (
handler: (dm: IDeliveredMessage, result: MessageProcessResult) => Promise<MessageProcessResult>
) => void;
/**
* @summary
* The handler is started first in the call chain.
* Depending on the needs of the library user, the message can either be passed down the chain of handlers
* `return true`, or the message `return false` can be ignored
*/
beforeExecute: (handler: (dm: IDeliveredMessage) => Promise<boolean>) => void;
/**
* @summary
* The handler is called in case of an exception in the client code
*
*/
onException: (handler: (error: Error, dm: IDeliveredMessage) => Promise<boolean>) => void;
/**
* @summary
* Called if a message has arrived for which a handler is not assigned
*/
onUnexpectedTopic: (handelr: (dm: IDeliveredMessage) => Promise<MessageProcessResult>) => void;
}
In general, I really need onException.
Let's discuss it, and I could implement this improvement myself, if possible, once we approve the interface and other details.
This functionality is already exists inside library. You can use:
middleware (array) - Array of middleware functions that extends RMQPipeClass with one method transform. They will be triggered right after recieving message, before pipes and controller method. Trigger order is equal to array order.
errorHandler (class) - custom error handler for dealing with errors from replies, use errorHandler in module options and pass class that extends RMQErrorHandler.
intercepters (array) - Array of intercepter functions that extends RMQIntercepterClass with one method intercept. They will be triggered before replying on any message. Trigger order is equal to array order.
I propose to implement the following post and pre handlers in the library in which the library user would be able to handle calls at his discretion:
In general, I really need onException.
Let's discuss it, and I could implement this improvement myself, if possible, once we approve the interface and other details.