如何连接到部署到 OpenShift 的 IBM MQ? [英] How to connect to IBM MQ deployed to OpenShift?

查看:27
本文介绍了如何连接到部署到 OpenShift 的 IBM MQ?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 IBM MQ(Docker 映像 ibmcom/mq/9.2.2.0-r1)的容器,暴露了两个端口(9443 - 管理员,1414 - 应用程序).

I have a container with IBM MQ (Docker image ibmcom/mq/9.2.2.0-r1) exposing two ports (9443 - admin, 1414 - application).

OpenShift 中所有必需的设置都已完成(Pod、Service、Routes).

All required setup in OpenShift is done (Pod, Service, Routes).

有两条路线,每个港口一条.

There are two routes, one for each port.

相应地指向端口(外部端口默认为 http=80、https=443).

pointing to the ports accordingly (external ports are default http=80, https=443).

可以通过第一条路径访问管理控制台,因此 MQ 已启动并运行.

Admin console is accessible through the first route, hence, MQ is up and running.

我尝试使用标准方法作为客户端(JMS 2.0,com.ibm.mq.allclient:9.2.2.0)进行连接:

I tried to connect as a client (JMS 2.0, com.ibm.mq.allclient:9.2.2.0) using standard approach:

  var fctFactory = JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER);
  var conFactory = fctFactory.createConnectionFactory();

  // ... other props

  conFactory.setObjectProperty(WMQConstants.WMQ_HOST_NAME, "route-app.my.domain");
  conFactory.setObjectProperty(WMQConstants.WMQ_PORT, 443);

连接失败.还尝试将路由重新定义为 HTTP 并使用端口 80,但再次失败.

and failed to connect. Also tried to redefine route as HTTP and use port 80, and again without success.

如果有帮助,我们假设我们使用最新版本的 MQ Explorer 作为客户端.

If it helps let's assume we use the latest version of MQ Explorer as a client.

每次出现同样的连接错误:

Each time the same connection error appears:

...
Caused by: com.ibm.mq.MQException: JMSCMQ0001: 
           IBM MQ call failed with compcode '2' ('MQCC_FAILED') reason '2009' ('MQRC_CONNECTION_BROKEN').
... 
Caused by: com.ibm.mq.jmqi.JmqiException: 
           CC=2;RC=2009;AMQ9204: Connection to host 'route-app.my.domain(443)' rejected.
           [1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2009;AMQ9208: 
            Error on receive from host 'route-app.my.domain/10.227.248.2:443 (route-app.my.domain)'.
           [1=-1,2=ffffffff,3=route-app.my.domain/10.227.248.2:443 (route-app.my.domain),4=TCP]],
            3=route-app.my.domain(443),5=RemoteConnection.receiveTSH]
...
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2009;AMQ9208: 
           Error on receive from host 'route-app.my.domain/10.227.248.2:443

也许,这篇文章可以给出一些关于错误代码 2009 的提示,但仍然不确定究竟是什么影响了 OpenShift 端的连接错误.

Maybe, this article could give some hints about error code 2009, but still not sure what exactly affects connection errors from the OpenShift side.

以前,我总是连接到 IBM MQ,明确指定端口值,但这里的情况有点不同.
如何通过 TCP 连接 OpenShift 集群中的 IBM MQ?

Previously, I always connected to IBM MQ specifying a port value explicitly, but here is a bit different situation.
How to connect to IBM MQ in OpenShift cluster through TCP?

OpenShift中的配置如下:

Configurations in OpenShift are as follows:

kind: Pod
apiVersion: v1
metadata:
  name: ibm-mq
  labels:
    app: ibm-mq
spec:
  containers:
    - resources:
        limits:
          cpu: '1'
          memory: 600Mi
        requests:
          cpu: '1'
          memory: 600Mi
      name: ibm-mq
      ports:
        - containerPort: 1414
          protocol: TCP
        - containerPort: 9443
          protocol: TCP
  containerStatuses:
      image: 'nexus-ci/docker-lib/ibm_mq:latest'

---
   
kind: Service
apiVersion: v1
metadata:
  name: ibm-mq
spec:
  ports:
    - name: admin
      protocol: TCP
      port: 9443
      targetPort: 9443
    - name: application
      protocol: TCP
      port: 1414
      targetPort: 1414
  selector:
    app: ibm-mq

---

kind: Route
apiVersion: route.openshift.io/v1
metadata:
  name: ibm-mq-admin
spec:
  host: ibm-mq-admin.my-domain.com
  to:
    kind: Service
    name: ibm-mq
    weight: 100
  port:
    targetPort: admin
  tls:
    termination: passthrough
    insecureEdgeTerminationPolicy: None
  wildcardPolicy: None

---

kind: Route
apiVersion: route.openshift.io/v1
metadata:
  name: ibm-mq-app
spec:
  host: ibm-mq-app.my-domain.com
  to:
    kind: Service
    name: ibm-mq
    weight: 100
  port:
    targetPort: application
  tls:
    termination: passthrough
    insecureEdgeTerminationPolicy: None
  wildcardPolicy: None

---

更新:最终创建并部署到 OpenShift 的小型 Web 应用程序接收 HTTP 请求并通过 JMS(输入/获取文本消息)与 MQ 交互,例如:

UPDATE: Ended up with creating and deploying to OpenShift a small web-application receiving HTTP requests and interacting with MQ via JMS (put/get text messages), like:

  • POST/queue/{queueName}/send + <body>;
  • GET/queue/{queueName}/receive.

它使用 TCP 与 OpenShift 集群内的 MQ 交互,并接受外部 HTTP 连接作为常规 Web 应用程序.
其他解决方案似乎需要付出太多努力,但我接受了其中一种,因为它在理论上是正确且简单的.

It interacts with MQ inside the OpenShift cluster using TCP, and accepts external HTTP connections as a regular web application.
Other solutions seem to take too much efforts, but I accepted one of them as it is theoretically correct and straightforward.

推荐答案

我不确定是否完全理解您的设置,但Routes"仅路由 HTTP 流量(在端口 80 或 443onyl),而不是 TCP 流量.
如果你想从集群外部访问你的 MQ 服务器,有几种解决方案,一种是创建一个服务类型:NodePort"

I'm not sure to fully understand your setup, but"Routes"only route HTTP traffic (On ports 80 or 443 onyl), not TCP traffic.
If you want to access your MQ server from outside the cluster, there are a few solutions, one is to create a service of type: "NodePort"

文档:https://docs.openshift.com/container-platform/4.7/networking/configuring_ingress_cluster_traffic/configuring-ingress-cluster-traffic-nodeport.html

您的服务不是 NodePort 服务.在您的情况下,它应该类似于

Your Service is not a NodePort Service. In your case, it should be something like

kind: Service
apiVersion: v1
metadata:
  name: ibm-mq
spec:
  type: NodePort
  ports:
    - port: 1414
      targetPort: 1414
      nodePort: 30001
  selector:
    app: ibm-mq

然后使用任何名称从外部访问.<cluster domaine>:30001
并删除无用的对应路由.如前所述,我假设您阅读了我指向您的文档,该文档说该路由仅在端口 80 或 443 上路由 HTTP 流量.

Then access from outside with anyname.<cluster domaine>:30001
And delete the useless corresponding route. As said before, I assumed you read in the doc I pointed to you that says that route only route HTTP traffic on port 80 or 443.

文档:https://kubernetes.io/docs/concepts/服务网络/服务/#nodeport

这篇关于如何连接到部署到 OpenShift 的 IBM MQ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆