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).
20 lines • 1.73 kB
TypeScript
import { DatabaseClient } from '../common/database';
import { PollingListenerSettings } from '../polling/config';
import { ReplicationListenerSettings } from '../replication/config';
import { MessageNotFoundRetryStrategy } from '../strategies/message-not-found-retry-strategy';
import { StoredTransactionalMessage } from './transactional-message';
/**
* This function makes sure the message was not and is not currently being
* worked on and acquires a lock to prevent other processes to work with this
* message. It locks the record via `SELECT ... FOR NO KEY UPDATE`. It updates
* the message object and sets the started_attempts, finished_attempts,
* locked_until, and processed_at values (again) on the message to be sure no
* other process altered them.
* @param message The message for which to acquire a lock and set the updatable properties (again).
* @param client The database client. Must be part of the transaction where the message handling changes are later done.
* @param config The configuration settings for the polling or replication listener.
* @param messageNotFoundRetryStrategy The retry strategy if the message could not be found in the database.
* @returns 'MESSAGE_NOT_FOUND' if the message was not found, 'ALREADY_PROCESSED' if it was processed, and otherwise assigns the properties to the message and returns it.
*/
export declare const initiateMessageProcessing: (message: StoredTransactionalMessage, client: DatabaseClient, settings: PollingListenerSettings | ReplicationListenerSettings, messageNotFoundRetryStrategy: MessageNotFoundRetryStrategy) => Promise<true | "MESSAGE_NOT_FOUND" | "ALREADY_PROCESSED" | "ABANDONED_MESSAGE">;
//# sourceMappingURL=initiate-message-processing.d.ts.map