async function processQueuedEvents() {
    logger.debug('processing queued events');
    const client = await pgPool.connect();
    try {
        await client.query('BEGIN');
        const result = await client.query('SELECT q.* FROM outbound_queue q INNER JOIN pipeline p ON q.pipeline_id = p.id WHERE q.state = $1 AND p.batch_process = false AND p.active = true ORDER BY q.created_at FOR UPDATE SKIP LOCKED LIMIT $2', ['QUEUED', QUERY_BATCH_SIZE]);

        if (result.rows.length === 0) {
            await new Promise(resolve => setTimeout(resolve, DELAY_IF_NOEVENTS));
            await client.query('COMMIT');
            return;
        }

        await processEvents(client, result.rows, false); //batch mode must be false
        await client.query('COMMIT');
    } catch (err) {
        logger.error(err);
        await client.query('ROLLBACK');
        await new Promise(resolve => setTimeout(resolve, 5000));
    } finally {
        client.release();
    }
}
Method to process events in adhoc mode without an associated scheduled trigger