有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java IMB PCF代理在查询通道状态时返回错误

在查询通道以获取有关连接到给定队列管理器的主机的信息时,我遇到了PCF消息代理的问题。PCFAgent的代码为

 MQGetMessageOptions getMessageOptions = new MQGetMessageOptions();
 getMessageOptions.options = MQC.MQGMO_BROWSE_NEXT + MQC.MQGMO_NO_WAIT + MQC.MQGMO_FAIL_IF_QUIESCING;
 messageAgent = new PCFMessageAgent(MQEnvironment.hostname, MQEnvironment.port, MQEnvironment.channel);

选项代码是

 inquireOptions = new PCFMessage(CMQCFC.MQCMD_INQUIRE_CHANNEL_STATUS);
            inquireOptions.addParameter(CMQCFC.MQCACH_CHANNEL_NAME, "*");
            inquireOptions.addParameter(CMQCFC.MQIACH_CHANNEL_INSTANCE_TYPE, CMQC.MQOT_CURRENT_CHANNEL);
            inquireOptions.addParameter(CMQCFC.MQIACH_CHANNEL_INSTANCE_ATTRS, new int[]{
                    CMQCFC.MQCACH_CHANNEL_NAME, CMQCFC.MQCACH_CONNECTION_NAME, CMQCFC.MQIACH_MSGS,
                    CMQCFC.MQCACH_LAST_MSG_DATE, CMQCFC.MQCACH_LAST_MSG_TIME, CMQCFC.MQIACH_CHANNEL_STATUS
            });
            responses = messageAgent.send(inquireOptions); 

不总是,但偶尔应用程序会重新引发一个异常,该异常显示“完成代码2,原因2100”,并且我的主机(应用程序运行的主机)会在服务器上留下一个挂起的连接,该连接在MQManager重新启动之前从未关闭

我已经读到这个异常是由于创建动态队列时发生冲突造成的,但是在我的代码中我没有创建任何队列。 有人能帮我吗?对不起,我以前没有使用队列管理器的经验

多谢各位


共 (1) 个答案

  1. # 1 楼答案

    2100 (MQRC_OBJECT_ALREADY EXISTS)的确是创建动态队列的问题

    Explanation

    An MQOPEN call was issued to create a dynamic queue, but a queue with the same name as the dynamic queue already exists.

    Completion code

    MQCC_FAILED

    Programmer response

    If supplying a dynamic queue name in full, ensure that it obeys the naming conventions for dynamic queues; if it does, either supply a different name, or delete the existing queue if it is no longer required. Alternatively, allow the queue manager to generate the name.

    If the queue manager is generating the name (either in part or in full), reissue the MQOPEN call.

    在封面下,PCFMessageAgent将使用PCFMessage中提供的详细信息创建PCF格式的消息,并将打开一个模型队列来创建一个临时队列,以便从命令服务器接收回复。队列管理器通过使用时间戳生成一个唯一的部分来命名这些临时队列,从而产生一个类似AMQ.5E47207E2227AA02的名称。如果有很多并发应用程序执行此操作,则可能最终会出现名称冲突,而中的第二个请求可能同时会出现名称冲突

    如果您有办法在系统中出现并发问题时使临时队列名称更加唯一,则可以使用setReplyQueuePrefix方法设置临时队列名称的前缀。例如,如果用户ID是唯一的,则可以使用每个应用程序运行时使用的用户ID

    public void setReplyQueuePrefix(java.lang.String prefixP)

    Sets the string used as the first part of the agent's reply queue name. The reply queue used by the PCFAgent is a temporary dynamic queue. By default, the reply queue prefix used by the PCFAgent is the empty string (""). When this is used, the name of the reply queue is generated entirely by the queue manager. If the method is called with a prefix specified, then the PCFAgent will pass that prefix to the queue manager whenever it needs to create a temporary queue. The queue manager will then generate the rest of the temporary queue name. This means that the queue manager generates a unique name, but the PCFAgent still has some control. The prefix specified should be fewer than 33 characters. If the prefix contains 33 characters or greater, then this method will truncate the prefix to be 32 characters in length. If the prefix does not contain an asterisk (*) character at the end, then an asterisk will be added to the end.