JMS and IBM WebSphere not generating COD

2019-08-04 08:44发布

I am creating an application that consumes messages from a MQ using JMS. My MQ manager is IBM WebSphere MQ and I am using the IBM jms implementation to consume the messages.

The messasges are coming and going fine. I receive the messages from the other part and I can send messages to them. The problem is that they are not receiving the COD after I consume the message from the queue. They receive the COA, but no COD.

Here is my receive message code:

public byte[] readMsgFromClient() throws JMSException {
        byte[] message = null;
        QueueReceiver reader = null;
        try {
            connection = getQueueConnection();
            connection.start();
            session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

            Queue queue = session.createQueue(config.getQueueRsp());

            ((MQQueue) queue).setTargetClient(JMSC.MQJMS_CLIENT_NONJMS_MQ);

            reader = session.createReceiver(queue);

            JMSBytesMessage byteMessage = (JMSBytesMessage) reader.receive(3000);

            if (byteMessage != null) {
                message = new byte[(int) byteMessage.getBodyLength()];
                byteMessage.readBytes(message);
            }
        } finally {
            if (reader != null) {
                reader.close();
            }

            if (session != null) {
                session.close();
            }

            if (connection != null) {
                connection.close();
            }
        }

        return message;
    }

Do I have to manually send the COD? DO I have to configure my WebSphere to automatically send the COD? Do I have to notify the WebSphere that my application has consumed the message?

标签: jms ibm-mq
2条回答
放我归山
2楼-- · 2019-08-04 09:01

The COD messages are probably ending up the the dead letter queue (DLQ) with an RC (Reason Code) of 2035 (not authorized).

Here is another of those things you learn the hard way:

  • COA messages are generated under the queue manager's UserId
  • COD messages are generated under the UserId of the sender's message.

If the sending application's UserId is appl001 then the COD will be generated using the UserId of appl001. If that UserId does not have permission to write to the particular queue then the message will end up in the DLQ.

Generally, the permission issue happens when the sender application is connected to 1 queue manager and the receiver application is connected to another queue manager. i.e. messages are hoping between queue managers.

Hence, the sender's UserId does not have permission to put a message on the remote queue manager.

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-08-04 09:02

As stated by @Roger, the permissions to put the COD are based on the UserId in the MQMD of the message that is sent.

If you do not want to add the remote user to your local system you can use the itsoME exit provided in the IBM Redbook "Secure Messaging Scenarios with WebSphere MQ". The latest version is found under the "Additional Material" link.

With this exit you need to have a MCAUSER set on your RCVR or RQSTR channel and configure that channel with the following attributes:

MSGEXIT('itsoME(MsgExit)')
MSGDATA('MCA/')

The result is that UserIdentifier field of the MQMD will be changed to the value of the MCAUSER that is configured on the channel. You would then give that MCAUSER +put and +passid to the XMITQ that returns to the remote queue manager.

The exit can be used for other things such as removing the reporting options if you do not want to allow COA/COD.

查看更多
登录 后发表回答