MQ

 View Only
Expand all | Collapse all

Websphere MQ :: Not able to open Remote Queue

  • 1.  Websphere MQ :: Not able to open Remote Queue

    Posted Mon May 29, 2023 06:39 AM

    We are trying to open a remote queue with the below open option but it failed with the below error. what is the open option used to open a remote queue

    int openOptions = MQConstants.MQOO_INPUT_AS_Q_DEF | MQConstants.MQOO_INPUT_SHARED| MQConstants.MQOO_INPUT_EXCLUSIVE| MQConstants.MQOO_OUTPUT| MQConstants.MQOO_INQUIRE| MQConstants.MQOO_SET;  
            

    MQJE001: Completion Code 2, Reason 2045
    Exception in thread "main" com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2045
        at com.ibm.mq.MQQueueManager.accessQueue(MQQueueManager.java:2841)
        at com.ibm.mq.MQQueueManager.accessQueue(MQQueueManager.java:2898)
        at ReadMQ.main(ReadMQ.java:50)

    following is our code 

    mqht.put(CMQC.CHANNEL_PROPERTY,channel);
    mqht.put(CMQC.HOST_NAME_PROPERTY, host);
    mqht.put(CMQC.PORT_PROPERTY, new Integer(port));
    mqht.put(CMQC.USER_ID_PROPERTY, username);
    mqht.put(CMQC.PASSWORD_PROPERTY, password);
     
    manager=new MQQueueManager(queueManager, mqht);
     
     
    int openOptions = MQConstants.MQOO_INPUT_AS_Q_DEF | MQConstants.MQOO_INPUT_SHARED| MQConstants.MQOO_INPUT_EXCLUSIVE| MQConstants.MQOO_OUTPUT| MQConstants.MQOO_INQUIRE| MQConstants.MQOO_SET;  
    queue = manager.accessQueue("RemoteQueue",openOptions);
     
    MQGetMessageOptions gmo = new MQGetMessageOptions();
    gmo.options = MQConstants.MQGMO_WAIT + MQConstants.MQGMO_FAIL_IF_QUIESCING 
    + MQConstants.MQGMO_CONVERT + MQConstants.MQGMO_BROWSE_NEXT ;
     
    try {
     
    while(getMore)
    {
    MQMessage message = new MQMessage();
     
    queue.get(message, gmo);
    byte[] b = new byte[message.getMessageLength()];
    message.readFully(b);
    System.out.println(new String(b));
     
    }
     
    } catch (MQException e) {
    if (e.reasonCode == 2033)
                {
    System.out.println("No message available");
                }
     
    if ( (e.completionCode == CMQC.MQCC_FAILED) &&(e.reasonCode == CMQC.MQRC_NO_MSG_AVAILABLE) ) {
    }
    else
    {
    System.out.println("MQException: " + e.getLocalizedMessage());
    System.out.println("CC=" + e.completionCode + " : RC=" + e.reasonCode);
    getMore = false;
    }
     
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
     
     
    manager.disconnect();
    queue.close();
    }


    ------------------------------
    Ranjitha YM
    ------------------------------


  • 2.  RE: Websphere MQ :: Not able to open Remote Queue

    IBM Champion
    Posted Mon May 29, 2023 07:00 AM

    Hi Ranjitha,

    MQRC 2045 is MQRC_OPTION_NOT_VALID_FOR_TYPE. As you have correctly surmised, you are using an option that is not suitable for use with a remote queue.

    You can put messages to a remote queue, but you cannot get messages from a remote queue.

    When you intend to put messages to a queue, you open it using the option MQOO_OUTPUT.

    When you intend to get messages from a queue, you open it using one of the MQOO_INPUT_* options.

    Therefore, if you are using a remote queue, then the options which are causing your MQRC_OPTION_NOT_VALID_FOR_TYPE bad reason code are the MQOO_INPUT_* ones, because you cannot get from a remote queue.

    Now, having told you that, we must address a few other things.

    1. You should only use ONE of the MQOO_INPUT_* options - you have coded all three. 
    2. Your program appears to be trying to get messages - something that you cannot do from a remote queue. So, perhaps your open options are fine and you should not be using a remote queue.
    3. You are also using MQOO_SET, but your program does not appear to need this. Same for MQOO_INQUIRE. You should only use the open options that you need, don't code all of them "just in case".

    Perhaps if you tell us what it is you are trying to do, we can guide your further.

    Cheers,
    Morag



    ------------------------------
    Morag Hughson
    MQ Technical Education Specialist
    MQGem Software Limited
    Website: https://www.mqgem.com
    ------------------------------



  • 3.  RE: Websphere MQ :: Not able to open Remote Queue

    Posted Mon May 29, 2023 07:12 AM

    Our requirement is to read messages from the remote queue and write messages to it. what are the open options we need to use?



    ------------------------------
    Ranjitha YM
    ------------------------------



  • 4.  RE: Websphere MQ :: Not able to open Remote Queue

    IBM Champion
    Posted Mon May 29, 2023 06:43 PM

    Hi Ranjitha,

    You can only put messages to a QREMOTE. If you need to get messages, you must do so from a QLOCAL.

    The QREMOTE will point to a QLOCAL on another queue manager. To get messages from the QLOCAL you must make a connection to that queue manager where the QLOCAL is hosted. This will mean using different CHANNEL, HOST_NAME and PORT properties to connect to a different queue manager name.

    The open options in your program will work for a QLOCAL. Although you should make some changes based on my advice in the numbered list.

    Does this make sense? Are you able to connect to the queue manager hosting the QLOCAL?

    Cheers,
    Morag



    ------------------------------
    Morag Hughson
    MQ Technical Education Specialist
    MQGem Software Limited
    Website: https://www.mqgem.com
    ------------------------------



  • 5.  RE: Websphere MQ :: Not able to open Remote Queue

    Posted Tue May 30, 2023 02:23 AM

    Yes, we are able to access the local queue. What about Alias Queue and Model Queue, Can we do get and put operation to the queue of these types?



    ------------------------------
    Ranjitha YM
    ------------------------------



  • 6.  RE: Websphere MQ :: Not able to open Remote Queue

    IBM Champion
    Posted Tue May 30, 2023 02:32 AM

    Hi Ranjitha,

    I am happy to hear that you have managed to get to your remote queue by connecting to the queue manager hosting the local queue.

    For an alias queue, you can use it with the same options that would be applicable to the queue it is referencing. So, for example, if an QALIAS was referencing a QLOCAL in its TARGET attribute, then you can use the same options that you would use to open the QLOCAL directly. If the QALIAS is referencing a QREMOTE or a TOPIC, then the options you could make use of would differ accordingly.

    For a model queue, opening that type of queue results in the creation of a dynamic local queue. It is either a temporary dynamic queue or a permanent dynamic queue based on the DEFTYPE attribute of the QMODEL. Once created it behaves generally like a QLOCAL and so the attributes you can use when opening it are the same as you would use for a QLOCAL.

    It is rather unusual for an application to need to use all of these different types of queue in one application. Could you tell us a little more about what your application is doing that it needs to cover all these different types of queues. Usually, the application would be more along the lines of "I need to put messages" or "I need to get messages" and then the queue name you give the application to use just needs to be appropriate for doing that task. If the queue name it was given results in MQRC_OPTION_NOT_VALID_FOR_TYPE then the application would report back to the user that the queue was not appropriate for whatever it was trying to do, e.g. in your case "cannot use this queue for getting messages".

    Cheers,
    Morag



    ------------------------------
    Morag Hughson
    MQ Technical Education Specialist
    MQGem Software Limited
    Website: https://www.mqgem.com
    ------------------------------



  • 7.  RE: Websphere MQ :: Not able to open Remote Queue

    Posted Tue May 30, 2023 03:13 AM

    Got it, Thank You 



    ------------------------------
    Ranjitha YM
    ------------------------------



  • 8.  RE: Websphere MQ :: Not able to open Remote Queue

    Posted Tue May 30, 2023 07:07 AM

    We tried to put message data to the remote queue with the below open option but it failed with "failed to open error " MQJE001: Completion Code 2, Reason 2045

    mqht.put(CMQC.CHANNEL_PROPERTY,channel);
    mqht.put(CMQC.HOST_NAME_PROPERTY, host);
    mqht.put(CMQC.PORT_PROPERTY, new Integer(port));
    mqht.put(CMQC.USER_ID_PROPERTY, username);
    mqht.put(CMQC.PASSWORD_PROPERTY, password);
     
    manager=new MQQueueManager(queueManager, mqht);
     
    int openOptions = MQConstants.MQOO_INPUT_AS_Q_DEF|MQConstants.MQOO_OUTPUT ;      
    queue = manager.accessQueue("RemoteQueue",openOptions);
     
    MQGetMessageOptions gmo = new MQGetMessageOptions();
    gmo.options = MQConstants.MQGMO_WAIT + MQConstants.MQGMO_FAIL_IF_QUIESCING 
    + MQConstants.MQGMO_CONVERT + MQConstants.MQGMO_BROWSE_NEXT ;
    MQMessage msg = new MQMessage();
    msg.writeString("message from standalone app without format");
    MQPutMessageOptions pmo = new MQPutMessageOptions();
    queue.put(msg, pmo);
    manager.disconnect();
    queue.close();


    ------------------------------
    Ranjitha YM
    ------------------------------



  • 9.  RE: Websphere MQ :: Not able to open Remote Queue

    IBM Champion
    Posted Tue May 30, 2023 07:58 AM

    Hi Ranjitha,

    As mentioned before, you cannot get messages from a remote queue, so therefore you cannot use any of the MQOO_INPUT_* options with a remote queue as those are the options which indicate you are opening this queue for the purpose of getting messages from it.

    For a remote queue, just use open options of MQOO_OUTPUT to allow you to put to the queue.

    Since you are only putting messages to this queue, your application can also delete the references to "gmo".

    Cheers,
    Morag



    ------------------------------
    Morag Hughson
    MQ Technical Education Specialist
    MQGem Software Limited
    Website: https://www.mqgem.com
    ------------------------------



  • 10.  RE: Websphere MQ :: Not able to open Remote Queue

    IBM Champion
    Posted Tue May 30, 2023 04:24 PM

    > int openOptions = MQConstants.MQOO_INPUT_AS_Q_DEF|MQConstants.MQOO_OUTPUT ;      

    Change that line to be:

    int openOptions = MQConstants.MQOO_OUTPUT |  MQConstants.MQOO_FAIL_IF_QUIESCING;     

    And then it will work.



    ------------------------------
    Roger Lacroix
    CTO
    Capitalware Inc.
    London ON Canada
    https://capitalware.com
    ------------------------------



  • 11.  RE: Websphere MQ :: Not able to open Remote Queue

    Posted Wed May 31, 2023 02:08 AM

    we updated the open option to  "  int openOptions = MQConstants.MQOO_OUTPUT |  MQConstants.MQOO_FAIL_IF_QUIESCING;  " then we tried to put data to the remote queue, without an error program executed. Ho to view the record that got inserted.

    Our program connected to QManager "QM_YMR" and Queue "RemoteQueue"

    Queue "RemoteQueue"  is pointing to another QManager ( Qmanager Name: QM_NOAUTH Queue Name: RemoteQ)

    Our understanding is that the data inserted will be in  Qmanager Name: QM_NOAUTH Queue Name: RemoteQ. But not able see it.

    Is our understanding correct?




    MQQueueManager manager;
    MQQueue queue = null;
    boolean getMore = true;
     
    Hashtable<String, Object> mqht = new Hashtable<>();
     
    mqht.put(CMQC.CHANNEL_PROPERTY,channel);
    mqht.put(CMQC.HOST_NAME_PROPERTY, host);
    mqht.put(CMQC.PORT_PROPERTY, new Integer(port));
    mqht.put(CMQC.USER_ID_PROPERTY, username);
    mqht.put(CMQC.PASSWORD_PROPERTY, password);
     
    manager=new MQQueueManager(queueManager, mqht);
     
    //int openOptions = MQConstants.MQOO_INPUT_AS_Q_DEF|MQConstants.MQOO_OUTPUT ;    
    int openOptions = MQConstants.MQOO_OUTPUT | MQConstants.MQOO_FAIL_IF_QUIESCING; ;    
    queue = manager.accessQueue("RemoteQueue",openOptions);
     
    MQGetMessageOptions gmo = new MQGetMessageOptions();
    gmo.options = MQConstants.MQGMO_WAIT + MQConstants.MQGMO_FAIL_IF_QUIESCING 
    + MQConstants.MQGMO_CONVERT + MQConstants.MQGMO_BROWSE_NEXT ;
    MQMessage msg = new MQMessage();
    //msg.userId="adminqa";
    //msg.format="MQSTR";
    msg.writeString("message from standalone app without format");
    MQPutMessageOptions pmo = new MQPutMessageOptions();
    queue.put(msg, pmo);
    manager.disconnect();
    queue.close();










    ------------------------------
    Ranjitha YM
    ------------------------------



  • 12.  RE: Websphere MQ :: Not able to open Remote Queue

    IBM Champion
    Posted Wed May 31, 2023 02:14 AM

    Hi Ranjitha,

    Have you looked on queue manager QM_NOAUTH yet? Your screen shot does not show that queue manager so it is unclear.

    Because you are using a queue manager cluster (I am making this assumption because the transmission queue in your screenshot is SYSTEM.CLUSTER.TRANSMIT.QUEUE), the channels to move the messages from your queue manager QM_YMR to the queue manager QM_NOAUTH should be automatically defined and started. However, perhaps you should confirm that they are indeed running if you don't see the message on the queue when you look on queue manager QM_NOAUTH.

    Cheers,
    Morag



    ------------------------------
    Morag Hughson
    MQ Technical Education Specialist
    MQGem Software Limited
    Website: https://www.mqgem.com
    ------------------------------



  • 13.  RE: Websphere MQ :: Not able to open Remote Queue

    Posted Wed May 31, 2023 02:21 AM

    Yes QM_NOAUTH is there I have inserted two messages but queue depth not showing any number 





    ------------------------------
    Ranjitha YM
    ------------------------------



  • 14.  RE: Websphere MQ :: Not able to open Remote Queue

    IBM Champion
    Posted Wed May 31, 2023 03:12 AM

    Hi Ranjitha,

    OK - so now take a look at the channels and check that the channel from QM_YMR to QM_NOAUTH is running. This channel is what moves the message you put, onto the target queue at QM_NOAUTH. It cannot get there without this channel being in running status.

    However, I also notice that the queue called RemoteQ on QM_NOAUTH is itself a QREMOTE so it must be sending the messages on somewhere else. Is there a reason this queue is not defined as a QLOCAL? There is no Current Depth attribute on a QREMOTE. You have to find where the final target QLOCAL is to find the messages (and start all the required channels since you have multiple hops).

    Cheers,
    Morag



    ------------------------------
    Morag Hughson
    MQ Technical Education Specialist
    MQGem Software Limited
    Website: https://www.mqgem.com
    ------------------------------



  • 15.  RE: Websphere MQ :: Not able to open Remote Queue

    Posted Wed May 31, 2023 04:34 AM

    the messages that I inserted are going to the transmission queue, when I click on select for transmission queue am getting only two options.

    Where to specify the channel between QM_YMR and QM_NOAUTH


    I inserted the message "message from standalone app without format" but when I browse the transmission queue it shows different data 





    ------------------------------
    Ranjitha YM
    ------------------------------



  • 16.  RE: Websphere MQ :: Not able to open Remote Queue

    IBM Champion
    Posted Wed May 31, 2023 05:18 AM

    Hi Ranjitha,

    Yes, this is expected and normal behaviour. When you put a message to a QREMOTE, it is held in a special queue called a transmission queue until the channel reading that transmission queue can move it to the target queue manager. The format you are seeing is specific to messages on a transmission queue and refers to the MQXQH (Transmission Queue Header) which contains two fields, the target queue name and the target queue manager name. When the message moves over the channel to the target queue manager, the receiver channel will strip off this header and put your original message to the queue and queue manager name held in this header.

    The fact that your QREMOTE is defined to use the SYSTEM.CLUSTER.TRANSMIT.QUEUE led me to believe you had set up a queue manager cluster. Is this the case? Your last screen shot shows the "Queue Manager Clusters" folder in the navigation pane without a triangle to the left of it, suggesting there is no structure inside this folder which makes me think that maybe you haven't set up a cluster at all. Can you tell me why you used the SYSTEM.CLUSTER.TRANSMIT.QUEUE in your QREMOTE definition?

    Normally, a QREMOTE would refer to a transmission queue, and a sender (SDR) channel would be defined to read from the same transmission queue and to move the messages to the target queue manager system. Have you set up any such definitions? Also, on the target queue manager a receiver (RCVR) channel with the same name as the sender would be defined.

    If you're not sure about any of this, would it be sensible at this point to do some MQ education about remote messaging? If yes, I run online training courses and have one on this very subject that you could do today.

    Cheers,
    Morag



    ------------------------------
    Morag Hughson
    MQ Technical Education Specialist
    MQGem Software Limited
    Website: https://www.mqgem.com
    ------------------------------



  • 17.  RE: Websphere MQ :: Not able to open Remote Queue

    Posted Wed May 31, 2023 02:16 AM


    I sometimes see developers /vendors doing this and it makes no sense. If you intend to put to a queue then open it with output only - that way it will work with local queues or remote or cluster queues. We have seen vendors deliver applications that have never been tested on anything other than local queues, but fail in our clustered environment.

    If you intend to get from a queue then do not open it with output. This is also important for security access control reasons so that the application can be granted just the access that it needs and no more. The same principles apply to any queue including model queues.

    I have seen developers open model queues for output when they actually only needed to get messages from it. I have also seen them open the dynamic queue a second time explicitly, when the open of the model queue has already provided a queue handle that can be used to access the dynamic queue.

    Using the "API exerciser" (part of MO71) is a great way to become more familiar with the MQI.



    ------------------------------
    Peter T
    ------------------------------



  • 18.  RE: Websphere MQ :: Not able to open Remote Queue

    Posted Wed May 31, 2023 01:28 PM
    Edited by Richard Nikula Wed May 31, 2023 01:57 PM

    Perhaps sending this discussion completely in a different direction, but IF this really is configured as a Cluster and you want to put messages to this queue, a remote queue is not needed at all.  Once "testff" is defined as a cluster queue on QM_NOAUTH, than an application can put a message to it directly on QM_YMR.  From the MQ Explorer it won't show up but it would work if an application tried to do it. As noted, above, you still cannot read it from QM_YMR only from QM_NOAUTH.  



    ------------------------------
    Richard Nikula
    VP, Product development and support
    meshIQ (formerly Nastel Technologies)
    Plainview NY
    1 (516) 801-2100
    ------------------------------



  • 19.  RE: Websphere MQ :: Not able to open Remote Queue

    Posted Wed May 31, 2023 06:22 PM

    Hi Ranjitha,

    Having read through all the responses back and forth between you and Morag, I think you are not grasping some fundamental understandings of using the different types of MQ queues, their relationships, and message movement in general. 

    Now, I know Morag offers some incredible online training (as she mentioned) and do not wish to deter anyone from taking advantage of it, but the first thing I always ask -- Have you read the MQ Primer?  https://www.redbooks.ibm.com/redpapers/pdfs/redp0021.pdf   It is an excellent introduction to MQ by Morag's old buddy Mark Taylor.   Please take the time to read it from 0 to 99 - actually 50 - and increase your understanding of what MQ can do for you and how to use it properly.

    David



    ------------------------------
    ----------------------------------------------------------------------
    David Awerbuch
    MQ admin, MQ developer, MQ firefighter, real firefighter.
    ------------------------------