Config File

The cbq config file is where you define Queue Connections as well as Worker Pools. These Connections and Worker Pools can also be added, removed, or modified based on the current environment. When you want to change where your queued Jobs are sent or how they are worked, this is the file you will modify.

Definitions

Queue Connections

Also referred to as "Connection." A Queue Connection defines where Jobs are serialized and the default settings that apply.

configure

The configure method is where the production Queue Connection and Worker Pools definitions are constructed.

newConnection

This command creates a new QueueConnectionDefinition builder component. It requires a unique name that will define this Connection and that will be used when defining Worker Pools.

component {

    function configure() {
        newConnection( "default" );
    }

}

A QueueConnectionDefinition has various methods to configure the Queue Connection.

newWorkerPool

This command creates a new WorkerPoolDefinition builder component. It requires a unique name that will define this Worker Pool and a connectionName that points to an already created Connection.

component {

    function configure() {
        newConnection( "default" );
        
        newWorkerPool( "default" ).forConnection( "default" );
    }

}

A WorkerPoolDefinition has various methods to configure the Worker Pool.

reset

Removes all Connections and Worker Pools

getInstance( "Config@cbq" ).reset();

Environment Overrides

Just as in your config/ColdBox.cfc file or in ModuleConfig.cfc files, you can add, remove, or modify Queue Connection or Worker Pool definitions per environment. You do this by defining a method on your Config component matching the environment name you want to override.

component {

    function configure() {
        newConnection( "default" )
            .provider( "DBProvider@cbq" );
            
        newWorkerPool( "default" )
            .forConnection( "default" )
            .quantity( 3 )
            .timeout( 15 );
    }
    
    /**
     * This method will be called after `configure`
     * and only if the current environment is `development`.
     */
    function development() {
        withConnection( "default" )
            .provider( "SyncProvider@cbq" );
            
        withWorkerPool( "default" )
            .quantity( 1 )
            .timeout( 60 );
    }

}

withConnection

Retrieves an already defined Queue Connection Definition for overriding. All the same methods are available.

delete

This method is not yet implemented.

withWorkerPool

Retrieves an already defined Worker Pool Definition for overriding. All the same methods are available.

delete

This method is not yet implemented.

Last updated