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.

Arguments
Type
Required
Default
Description

name

string

true

The unique name for the new Queue Connection.

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.

Arguments
Type
Required
Default
Description

name

string

true

The unique name for the new Worker Pool.

connectionName

string

false

A reference to an existing Connection. If not passed in here, the forConnection method must be called to define the Connection.

quantity

numeric

false

1

The number of workers to spin up for this Worker Pool.

queues

array

false

[ * ]

An array of queues that this Worker Pool will work. A queue of * refers to all queues. Queues will be worked in the order provided.

force

boolean

false

false

If false, an exception will be thrown if the Worker Pool name has already been registered. If true, the new definition will override the existing definition.

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.