简体   繁体   English

在 JMS 中使用 CCDT 文件连接到 IBM MQ

[英]Connecting to IBM MQ using CCDT file in JMS

I am trying to connect to IBM MQ using JMS and client channel definition table (CCDT).我正在尝试使用 JMS 和客户端通道定义表 (CCDT) 连接到 IBM MQ。 I was able to connect successfully to the QueueManager when i specify the MQ properties individually.当我单独指定 MQ 属性时,我能够成功连接到 QueueManager。 But when i try to use CCDT file i get the below exception.但是当我尝试使用 CCDT 文件时,出现以下异常。

As client channel definition table (CCDT) is used to determine the channel definitions used by client applications to connect to the queue manager i didnt set QueueManager Name.由于客户端通道定义表 (CCDT) 用于确定客户端应用程序用于连接到队列管理器的通道定义,因此我没有设置 QueueManager Name。

ERROR> com.ssc.ach.mq.JMSMQReceiver[main]: errorMQJMS2005: failed to create MQQueueManager for ''
javax.jms.JMSException: MQJMS2005: failed to create MQQueueManager for ''
    at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:586)
    at com.ibm.mq.jms.MQConnection.createQM(MQConnection.java:2110)
    at com.ibm.mq.jms.MQConnection.createQMNonXA(MQConnection.java:1532)
    at com.ibm.mq.jms.MQQueueConnection.<init>(MQQueueConnection.java:150)
    at com.ibm.mq.jms.MQQueueConnectionFactory.createQueueConnection(MQQueueConnectionFactory.java:174)
    at com.ibm.mq.jms.MQQueueConnectionFactory.createConnection(MQQueueConnectionFactory.java:1066)

Iam using the .setCCDTURL(ccdt);我正在使用.setCCDTURL(ccdt); method to set the CCDT URL.设置CCDT URL的方法。

private MQQueueConnectionFactory  mqQueueConnectionFactory = new MQQueueConnectionFactory();
         mqQueueConnectionFactory.setCCDTURL(ccdt);
         queueConnection = mqQueueConnectionFactory.createConnection(username, pwd);

When i try to connect using below configuration instead of the CCDT file it connects to the MQ.当我尝试使用以下配置而不是 CCDT 文件进行连接时,它会连接到 MQ。

         mqQueueConnectionFactory.setHostName(host);
         mqQueueConnectionFactory.setChannel(channel);
         mqQueueConnectionFactory.setPort(port);
         mqQueueConnectionFactory.setQueueManager(qManager);
         mqQueueConnectionFactory.setTransportType(1);

Do i need to set setQueueManager as well along with the CCDT file , as the exception says failed to create MQQueueManager for ''我是否需要设置 setQueueManager 以及 CCDT 文件,因为异常说failed to create MQQueueManager for ''

The CCDT is not meant to be read in a text editor, it is a binary formatted file. CCDT 不打算在文本编辑器中读取,它是一个二进制格式的文件。 One of the parameters in the CCDT for each CLNTCONN channel is QMNAME .每个CLNTCONN通道的 CCDT 中的参数之一是QMNAME Knowing what QMNAME is set to and how many CLNTCONN channels you have defined in the CCDT and what you want to accomplish will help figure out what value if any should be specified for with setQueueManager .了解QMNAME设置为什么以及您在 CCDT 中定义了多少个CLNTCONN通道以及您想要完成什么将有助于确定应该为setQueueManager指定什么值(如果有的setQueueManager


If there is only one CLNTCONN channel then you could specify the following and it will connect using the single channel no matter what the QMNAME property is set to:如果只有一个CLNTCONN通道,那么您可以指定以下内容,无论 QMNAME 属性设置为什么,它都将使用单个通道进行连接:

setQueueManager("*");

If there is more than one CLNTCONN channel in the file each with a different QMNAME specified, assuming the name matches the actual queue manager name listening on the host and port associated with the channel you would pass the queue manager name:如果文件中有多个CLNTCONN通道,每个通道都指定了不同的QMNAME ,假设名称与侦听与通道关联的主机和端口的实际队列管理器名称匹配,您将传递队列管理器名称:

setQueueManager("QMGRNAME");

If there is more than one CLNTCONN channels in the file each with the same QMNAME specified where this name is not meant to reflect a actual queue manager name listening on the host and port associated with each channel, this is known as a queue manager group, this would be intended where you want the client to connect to any number of different hosts and ports and you do not need to know which queue manager you are connecting to, in this case you would pass the queue manager group name prefixed with a * :如果文件中有多个CLNTCONN通道,每个通道都指定了相同的QMNAME ,但该名称并不意味着反映在与每个通道关联的主机和端口上侦听的实际队列管理器名称,这称为队列管理器组,这适用于您希望客户端连接到任意数量的不同主机和端口,并且您不需要知道要连接到哪个队列管理器的情况,在这种情况下,您将传递以*为前缀的队列管理器组名称:

setQueueManager("*QMGRGROUPNAME");

Another variation of the above is if there is more than one CLNTCONN channels in the file each with an all blank (spaces) or NULL QMNAME specified, this is known as a queue manager group, this would be intended where you want the client to connect to any number of different hosts and ports and you do not need to know which queue manager you are connecting to, in this case you would pass the queue manager name as either a single space上述的另一种变体是,如果文件中有多个CLNTCONN通道,每个通道都指定了全空白(空格)或 NULL QMNAME ,这称为队列管理器组,这将用于您希望客户端连接的位置到任意数量的不同主机和端口,并且您不需要知道要连接到哪个队列管理器,在这种情况下,您可以将队列管理器名称作为单个空格传递or nothing at all ``:或者什么都没有``:

setQueueManager(" ");
//or
setQueueManager("");

The last use case above would likely work if you did not use setQueueManager at all.如果您根本不使用 setQueueManager,上面的最后一个用例可能会起作用。


If you want to view the contents of the CCDT, you can use the runmqsc command that comes as part of the MQ v8 and higher client or server install.如果要查看 CCDT 的内容,可以使用作为 MQ v8 和更高版本客户端或服务器安装的一部分提供的 runmqsc 命令。

For Unix ksh/bash shells use the following:对于 Unix ksh/bash shell,请使用以下命令:

export MQCHLLIB=PATH/OF/CCDT
export MQCHLTAB=NAME_OF_CCDT
runmqsc -n

For Windows use the following:对于 Windows,请使用以下内容:

set MQCHLLIB=PATH/OF/CCDT
set MQCHLTAB=NAME_OF_CCDT
runmqsc -n

Once the runmqsc program has started and displayed Starting local MQSC for 'NAME_OF_CCDT'.一旦 runmqsc 程序启动并显示Starting local MQSC for 'NAME_OF_CCDT'. you can run the following command to see the channel details:您可以运行以下命令查看频道详细信息:

DIS CHL(*)

Below is a more specific command to narrow the number of fields returned:下面是一个更具体的命令来缩小返回的字段数量:

DIS CHL(*) QMNAME CONNAME

I haven't look at it in a while but I thought the correct format is:我有一段时间没有看它,但我认为正确的格式是:

MQQueueConnectionFactory qcf = new MQQueueConnectionFactory();
qcf.setQueueManager(qManager);
qcf.setCCDTURL(ccdt);
conn = qcf.createConnection(username, pwd);

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

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