Menu Search

12.4. Broker Customization

To customize broker before building the container image, its configuration files may be edited to start broker with queues, exchanges, users or other objects.

The file config.json contains definitions of the broker objects and references a file containing definitions of virtualhost objects (exchanges and queues).

It may be helpful first to create broker objects needed via broker web GUI or via REST API, and then investigate the configuration files and copy the appropriate definitions to the configuration files used for container image creation.

An example of the default initial configuration JSON file is provided in broker book (chapter 5.7).

12.4.1. Exchanges

To create exchanges a JSON element "exchanges" should be created containing an array of single exchange definitions:

    "exchanges" : [ {
        "name" : "amq.direct",
        "type" : "direct"
      }, {
        "name" : "amq.fanout",
        "type" : "fanout"
      }, {
        "name" : "amq.match",
        "type" : "headers"
      }, {
        "name" : "amq.topic",
        "type" : "topic"
      }, {
        "name" : "request.QUEUE1",
        "type" : "topic",
        "durable" : true,
        "durableBindings" : [ {
        "arguments" : { },
        "destination" : "QUEUE1",
        "bindingKey" : "#"
      } ],
      "unroutableMessageBehaviour" : "REJECT"
    } ]
                

Information about exchanges, their types and properties can be found in broker book (chapter 4.6).

Please note that each virtualhost pre-declares several exchanges, described in the broker book (chapter 4.6.1).

12.4.2. Queues

To create queue a JSON element "queues" should be created containing an array of single queue definitions:

    "queues" : [ {
        "name" : "QUEUE1",
        "type" : "standard",
        "durable" : true,
        "maximumQueueDepthBytes" : 6144000,
        "maximumQueueDepthMessages" : 6000,
        "messageDurability" : "ALWAYS",
        "overflowPolicy" : "REJECT"
      }, {
        "name" : "QUEUE2",
        "type" : "standard",
        "durable" : true,
        "maximumQueueDepthBytes" : 6144000,
        "maximumQueueDepthMessages" : 6000,
        "messageDurability" : "ALWAYS",
        "overflowPolicy" : "REJECT"
      } ]
                

Information about queues, their types and properties can be found in broker book (chapter 4.7).

12.4.3. Users

Users can be defined in an authentication provider. Authentication providers are defined on broker level (file config.json).

Information about authentication providers, their types and properties can be found in broker book (chapter 8.1).

Examples for most commonly used authentication providers can be found below.

12.4.3.1. Anonymous Authentication Provider

    "authenticationproviders" : [ {
        "name" : "anon",
        "type" : "Anonymous"
    } ]
                    

For additional details see broker book (chapter 8.1.5).

12.4.3.2. Plain Authentication Provider

    "authenticationproviders" : [{
        "name" : "plain",
        "type" : "Plain",
        "secureOnlyMechanisms" : [],
        "users" : [ {
            "name" : "admin",
            "type" : "managed",
            "password" : "<PASSWORD>"
        } ]
    } ]
                    

For additional details see broker book (chapter 8.1.7).

12.4.3.3. ACL Rules

The ACL rules for users are defined in file broker.acl following the syntax:

                        ACL {permission} {<group-name>|<user-name>|ALL} {action|ALL} [object|ALL] [property=<property-values>]
                    

The predefined broker.acl file contains permissions for the 'admin' user:

    # account 'admin' - enabled all actions
    ACL ALLOW-LOG admin ALL ALL
                    

For additional details see broker book (chapter 8.3.2).

12.4.4. Overriding Broker Configuration

Customized configuration for the Broker-J instance can be used by replacing the files residing in the work folder with the custom ones, e.g. config.json or default.json. Put the replacement files inside a folder and map it as a volume to:

    docker run -d -p 5672:5672 -p 8080:8080 -v <DIRECTORY_ON_HOST>:/qpid-broker-j/work-override:Z --name qpid <IMAGE_NAME>
            

The contents of work-override folder will be copied over to work folder first time after the instance creation so that the broker will start with user-supplied configuration.