Not sure if this is the right forum for this question, but if not, I'm
sure someone will tell me.

I'm trying to interface an RPGIV program to a Java class to talk to a MQ
Series MQ Manager.  
I've done RPG to Java beore, but I've always used pretty simple
paramaters and such.
This one is a bit trickier so I'm seeking help.

Here's what I have:
Within my MQJBIND class, I have a method called "MQJBIND" that accepts
two java string objects as parms.

A second method in the class called "mGetOutput" that returns a java
string object and accepts as a parm, the reference to MQJBIND.

Here's the relevant java code:


public void init()
// Set up MQSeries environment = channel;

} // end of init  
   * @param qManager the MQSeriss Queue Manager name
   * @parm qname the MQSeries Queue Name
  public  MQJBIND(String qManager, String qName)
  { // begin MQJBIND
    // Set up MQ environment
    { // begin TRY MQJBIND
        // Create a connection to the queue manager
        qMgr = new MQQueueManager(qManager,MQC.MQCNO_STANDARD_BINDING);
        int openOptions = MQC.MQOO_INPUT_AS_Q_DEF |
                          MQC.MQOO_INQUIRE |
                          MQC.MQOO_SET |
                          MQC.MQOO_OUTPUT ;

        // Note. MQOO_INQUIRE & MQOO_SET are always included by default.

        // Now specify the queue that we wish to open, and the open

        local_queue =  qMgr.accessQueue(
                                null,           // default q manager
                                null,           // no dynamic q name
                                null);          // no alternate user id

    } // end TRY MQJBIND
    // If an error has occured in the above, try to identify what went
    // Was it an MQ error?
    catch (MQException ex)
    {  // begin CATCH MQJBIND
        if(ex.reasonCode == 2033 || ex.reasonCode == 2002)
            error_out = "EMPTY QUEUE";
            out_text = "";      
            error_out = "An MQ error occurred : Completion code " +
ex.completionCode +
                          " Reason code " + ex.reasonCode;
            out_text = "";      
    }  // end CATCH MQJBIND

  } // end MQJBIND

    * Method getOutput reads the message from the appropriate queue and
    * returns it in a String format.
    * MQ Queue.
    * @param MQJBIND class
  public static String getOutput(MQJBIND mqg)
  { // begin getOutput
        mqg.out_text = "";
        {  // begin try getOutput
            //check if queue is empty
            if ((mqg.qDepth = mqg.local_queue.getCurrentDepth()) > 0)   
                //System.out.println ("In MQJBind current depth is >
                MQMessage retrievedMessage = new MQMessage();
                // Set the get message options.. accept the defaults
                MQGetMessageOptions gmo = new MQGetMessageOptions();  
                // wait for a message to arrive
                gmo.options = MQC.MQGMO_WAIT;

                // unlimited wait for a message
                gmo.waitInterval = MQC.MQWI_UNLIMITED; 

                // get the message off the queue..
                // And prove we have the message by displaying the UTF
message text
                String msgText = retrievedMessage.readUTF();
              mqg.out_text = msgText;
                System.out.println("The message is: " + msgText);
                //System.out.println ("In MQJBind current depth is <=
                mqg.error_out = "EMPTY QUEUE";
                mqg.out_text = "";
        } // end try getOutput
        catch (MQException ex)
        { // begin catch MQException getOutput
            if(ex.reasonCode == 2033 || ex.reasonCode == 2002)
                mqg.error_out = "EMPTY QUEUE";
                mqg.out_text = "";      
                mqg.error_out = "An MQ error occurred : Completion code
" + ex.completionCode +
                              " Reason code " + ex.reasonCode;
                mqg.out_text = "";      
        }  // end catch MQException getOutput

        catch ( ex)
        { // begin catch getOutput
            mqg.error_out = "An error occurred whilst writing to the
message buffer: " + ex;
            mqg.out_text = "";  
        } // end catch getOutput
        return (mqg.out_text);

  } // end getOutput question do I prototype the MQJBIND method in my RPG
program to receive the reference to MQJBIND?

Here's what I did, but it doesn't like my prototype when I compile,
because I can't figure out what to use as the return data type on the

     D obj_ref         S               O   CLASS(*JAVA:'MQJBIND')
     D mqjbind         S               O   CLASS(*JAVA:'MQJBIND')
     D qManager        S               O
     D qChannel        S               O
     D qName           S               O
     D bytes           S               O

      * Prototype procedure to instantiate 'MQJBIND' class
     D MQJBIND         PR              O
     D                                     EXTPROC(*JAVA:
     D                                             'MQJBIND':
     D                                             *CONSTRUCTOR)

      * Prototype procedure to connect to QManager
     D MQJBINDM        PR            10i 0
<<<<-----this return value is incorrect, but I don't know how to fix!
     D                                     EXTPROC(*JAVA:
     D                                             'MQJBIND':
     D                                             'MQJBIND')
     D ManagerQ                            LIKE(qManager) CONST
     D NameQ                               LIKE(qName)    CONST

      * Prototype procedure to accept the DCN INFO FROM ISP
     D MQGetOutput     PR          1000a
     D                                     EXTPROC(*JAVA:
     D                                             'MQJBIND':
     D                                             'getOutput')
     D MqJBindObj                          LIKE(MQJBIND)

         // Instantiate the 'MQMJBind' class via the *CONSTRUCTOR
         obj_ref = MQJBIND();

        // Call the MQMJBIND Method to connect to the MQ Manager on
remote host
         mqjbind = MQJBINDM(obj_ref:qManager:qName);

        //  Call the 'MQGetOutput' method in class 'MQMJBind'
        Response = MQGetOutput(obj_ref:mqjbind);

Any help/suggestions appreciated. 

Shannon O'Donnell


This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2020 by and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].