Our Man in Bananas
Our Man in Bananas

Reputation: 5979

MQRC_ Errors when getting messages from iSeries Websphere Message Queue

We are using the below code to and settings to connect to the IBM Websphere Message Queue (version IBM(R) WebSphere(R) MQ V6.0.1) on an iSeries.

We use the same uid and pwd for three different applications against the same MQ

We get MQRC_NOT_AUTHORIZED and MQRC_Q_MGR_NOT_AVAILABLE errors intermittently throughout the day, but always on the Get messages method.

Settings:

A HashTable for the connection properties is created with the below settings:

MQC.TRANSPORT_PROPERTY = MQC.TRANSPORT_MQSERIES_MANAGED 
MQC.CHANNEL_PROPERTY    = SYSTEM.DEF.SVRCONN
MQC.HOST_NAME_PROPERTY = IP Address

We use the below Open Options:

MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING + MQC.MQOO_INQUIRE

class WebSphereMQ
{
    public bool impStatus { get; set; }

    public MQQueueManager gMQQueueManager;
    public MQQueue gMQQueue;
    private MQMessage queueGetMessage { get; set; }
    private MQGetMessageOptions queueGetMessageOptions { get; set; }

    public MQQueueManager pMQQueueManager;
    public MQQueue pMQQueue;
    private MQMessage queuePutMessage { get; set; }
    private MQPutMessageOptions queuePutMessageOptions { get; set; }

    public WebSphereMQ()
    {
        impStatus = impersonation.impersonateValidUser(Common.impNme, "", Common.impPwd);

        gMQQueueManager = null;
        gMQQueue = null;

        if (gMQQueue != null && gMQQueue.IsOpen)
        {
            // Just incase
            gMQQueue.Close();
            gMQQueueManager.Disconnect();
        }
    }

    public bool connectMQGet(string QMgr, string QName, Hashtable connectionProperties, bool BrowseOnly, string QType)
    {
        try
        {
            gMQQueueManager = new MQQueueManager(QMgr, connectionProperties);
            if (gMQQueueManager != null && QType == "OUT")
            {
                if (BrowseOnly)
                    gMQQueue = gMQQueueManager.AccessQueue(QName, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_BROWSE + MQC.MQOO_FAIL_IF_QUIESCING + MQC.MQOO_INQUIRE);
                else
                    gMQQueue = gMQQueueManager.AccessQueue(QName, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING + MQC.MQOO_INQUIRE);
            }
        }
        catch (MQException mqe)
        {
            if (impStatus) impersonation.undoImpersonation();
            /* Write to log */
            Common.logBuilder("WebSphereMQ --> connectMQGet <--", "MQException", Common.ActiveMQ, mqe.Message, "Exception");
            /* Send email to support */
            emailer.exceptionEmail(mqe);
            return false;
        }
        return true;
    }

Here is an example of the error and stack trace:

An MQException has happened on 30 June 2015 at 08:52A
Message ---
MQRC_NOT_AUTHORIZED
HelpLink ---
Source ---
amqmdnet
StackTrace ---
     at IBM.WMQ.MQBase.throwNewMQException() at IBM.WMQ.MQQueueManager.Connect(String queueManagerName) at IBM.WMQ.MQQueueManager..ctor(String queueManagerName, Hashtable properties) at EvryCardManagement.WebSphereMQ.connectMQGet(String QMgr, String QName, Hashtable connectionProperties, Boolean BrowseOnly, String QType)

So is there some setting I can change on the client side to prevent us getting these exceptions, or is this something that needs to be modified on the iSeries/MQ?

Should we try using different uid's for the three different applications hitting the MQ?

Upvotes: 2

Views: 258

Answers (1)

Shashi
Shashi

Reputation: 15283

MQ V6 went out of service long back. You will need to upgrade your queue manager to a supported version.

As far as the 2035 exception is concerned there are multiple ways to solve it:

1) The user id under which your MQ .NET application must exist on iSeries and has authority to connect to queue manager.

2) Set MCAUSER on SYSTEM.DEF.SVRCONN on iSeries queue manager.

There are many posts on 2035 reason code. Look at the following posts from T.Rob and links in these posts.

Authorization with Websphere MQ 6

WebSphere 7, configuring JMS Q connection factory without user id: MQRC_NOT_AUTHORIZED

Upvotes: 3

Related Questions