pg-transactional-outbox
Version:
A PostgreSQL based transactional outbox and inbox pattern implementation to support exactly once message processing (with at least once message delivery).
23 lines (20 loc) • 800 B
text/typescript
import { FullListenerConfig } from '../common/listener-config';
import { StoredTransactionalMessage } from '../message/transactional-message';
/**
* Defines how much time in milliseconds a given message is allowed to take
* before the processing of that message is cancelled.
* @param message The outbox or inbox message
* @returns The time in milliseconds for the timeout
*/
export interface MessageProcessingTimeoutStrategy {
(message: StoredTransactionalMessage): number;
}
/**
* Get the default message processing timeout strategy which uses the
* messageProcessingTimeoutInMs setting.
*/
export const defaultMessageProcessingTimeoutStrategy =
(config: FullListenerConfig): MessageProcessingTimeoutStrategy =>
() => {
return config.settings.messageProcessingTimeoutInMs;
};