简体   繁体   English

无法使用容器将消息放入 ibm mq

[英]Unable to put message in ibm mq using container

I have two docker containers which I'm building using docker-compose.我有两个使用 docker-compose 构建的 docker 容器。 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.其中一个初始化 ibm mqs,另一个是暴露其余端点(使用 SpringBoot 项目)以向第一个容器设置的 ibm mq 发送消息。 When I get the docker-compose up I am getting the below error当我得到 docker-compose up 时,我收到以下错误

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.如果我从我的 IDE 本地运行 SpringBoot 应用程序而没有任何错误,我可以将消息放在同一个队列中。 Not sure what is the issue using separate containers.不确定使用单独的容器有什么问题。 My DockerFile looks like this我的 DockerFile 看起来像这样

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和 config.mqsc

ALTER QMGR CHLAUTH(DISABLED)

docker-compose.yml 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.您的 spring 容器内的 Localhost 是您的 spring 容器。 Instead of setting the host to localhost for your MQ Connection you need your container's / host ip.您需要容器的 / 主机 ip,而不是为您的 MQ 连接将主机设置为 localhost。

How you do it depends on your host's platform, but it will be something like host.docker.internal你怎么做取决于你主机的平台,但它会像host.docker.internal

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM