I have two docker containers which I'm building using docker-compose. One of which initializes the ibm mqs and another is the one exposes rest end points(using SpringBoot project) to send message to the ibm mq which were set up by first container. When I get the docker-compose up I am getting the below error
mock-service_1 | 2020-01-29 08:07:52.928 ERROR 1 --- [nio-7090-exec-2] c.j.ids.controller.AcarsController : JMSWMQ0018: Failed to connect to queue manager 'QM1' with connection mode 'Client' and host name 'localhost(1414)'.
acars-mock-service_1 | com.ibm.msg.client.jms.DetailedIllegalStateException: JMSWMQ0018: Failed to connect to queue manager 'QM1' with connection mode 'Client' and host name 'localhost(1414)'. Caused by: com.ibm.mq.MQException: JMSCMQ0001: IBM MQ call failed with compcode '2' ('MQCC_FAILED') reason '2538' ('MQRC_HOST_NOT_AVAILABLE').
mock-service_1 | at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:203)
I'm able to put the messages in the same queue if I run the SpringBoot application locally from my IDE without any error. Not sure what is the issue using separate containers. My DockerFile looks like this
FROM ibmcom/mq
USER root
RUN useradd ibm-mq -G mqm && \
echo ibm-mq:passw0rd | chpasswd
USER mqm
COPY config.mqsc /etc/mqm/
EXPOSE 9443 1414
And config.mqsc
ALTER QMGR CHLAUTH(DISABLED)
docker-compose.yml
version: '3.3'
services:
ibm-mq-mock:
build:
context: ../mock-service/ibm-mq
dockerfile: Dockerfile
ports:
- 9443:9443
- 1414:1414
environment:
LICENSE: accept
MQ_QMGR_NAME: QM1
mock-service:
build:
context: ../mock-service
ports:
- 7090:7090
depends_on:
- ibm-mq-mock
environment:
MQ_QMGR_NAME: QM1
CHANNEL: DEV.ADMIN.SVRCONN
IBM_MQ_HOST: localhost
IBM_MQ_PORT: 1414
IBM_MQ_USERID: admin
IBM_MQ_PASSWORD: passw0rd
IBM_MQ_QUEUE: DEV.QUEUE.1
LOG_LEVEL: INFO
PROFILE: test
Localhost inside your spring container, is your spring container. Instead of setting the host to localhost for your MQ Connection you need your container's / host ip.
How you do it depends on your host's platform, but it will be something like host.docker.internal
Using your docker-compose.yml, you should be able to set
IBM_MQ_HOST: ibm-mq-mock