1
votes

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?

2
Did either of the answers provided solve your problem?JoshMc
Nope. The COA was not been sent by the MQ, instead some person long time ago in a glaxy far away made a DLL that respond the COA.Augusto César Martins Gil
The IBM MQ 7.5 Knowledge Center page "Types of message" says that both COA and COD messages are generated by the queue manager. I'm unsure how the DLL comes into this?JoshMc
Me too! I do not know how they did it, but it seems that it was done like this since forever and when we let the Queue Manager hadle it by itself, the COA was never sent, only the COD. We searched for the configurations of the queues and channels, but there was nothing about COA or COD. Sorry that I can not be more helpful.Augusto César Martins Gil
Note that COA/COD are generated based on reporting options set in the MQMD of a message when it is sent. If a COA reporting option is not set then it will not be generated by the queue manager. You can use the sample amqsbcg to view the reporting options on a message. If the app is sending COA/COD reporting options then MQ should respond. I'm a little unclear in that your question says the COD is not sent and they receive only COA, but in your comments you say COA was never sent only COD. My answer was related to COD. I would start by first checking what reporting options are sent.JoshMc

2 Answers

2
votes

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.

2
votes

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.