Search code examples
javaspring-bootdockerdocker-composeibm-mq

Create queues in IBM MQ (docker compose )


I'm developing a Spring Boot app which is using IBM MQ. I want all of that to be configured in the docker compose. But the problem is that in the app there are used custom queues that were created from the UI in the browser, example of application.yml file:

...
ibm:
  mq:
    queues:
      first: QUEUE1
      second: QUEUE2

How do I create these queues on the startup now when I'm I want to run it from the docker compose file? When I was running ibm mq manually I was using command like this:

docker run --env LICENSE=accept --env MQ_QMGR_NAME=QM1 --publish 1414:1414 --publish 9443:9443 --detach ibmcom/mq:latest

And now I'm almost doing the same but in the docker-compose.yml file:

...
 ibm-mq:
    image: 'ibmcom/mq:latest'
    container_name: ibm-mq
    ports:
      - "1414:1414"
      - "9443:9443"
    environment:
      - LICENSE = accept
      - MQ_QMGR_NAME = QM1

Is there any environment variables to create custom queues or how do I do that? I didn't find any solution to this.


Solution

  • Based on this information: Customizing the queue manager configuration, you can create a MQSC file named 20-config.mqsc with some config options that will be run when your queue manager is created. Just put it into the /etc/mqm directory on the image.

    So, create your 20-config.mqsc file like this:

    DEFINE QLOCAL(QUEUE1) REPLACE
    DEFINE QLOCAL(QUEUE2) REPLACE
    

    And map it to your docker-compose.yml as a volume like this:

      ibmmq:
        image: ibmcom/mq
        ports:
          - "1414:1414"
          - "9443:9443"
        environment:
          - LICENSE=accept
          - MQ_QMGR_NAME=QM1
        volumes:
          - <your 20-config.mqsc file path>:/etc/mqm/20-config.mqsc
    

    It works for me