MQ

MQ

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  MQPUT is writing more data than BufferLength value

    Posted Wed January 13, 2021 05:33 PM
    Mainframe question, IBM MQ for z/OS, MQ Version 9, Release 1.

    I am doing an MQPUT with a BufferLength value of 26. My Buffer is much larger, of course, but if I tell the MQPUT to use BufferLength = 26, why does it appear to write the full length of my Buffer (which is 10000 bytes)?

    There are two reasons I am convinced this is happening:
    1. When I look at the messages in the queue, the ones I wrote have the first 26 bytes contain my intended message data, and the next 9974 bytes contain LOW-VALUES (binary zero), which is how I had initialized the Buffer originally.
    2. When I later do an MQGET of that message using a 90 byte Buffer, I get an MQ warning, and the reason code MQRC_TRUNCATED_MSG_FAILED.

    Of course, I can handle the error (and am doing this as a workaround), but why does it appear that the MQPUT is writing my entire Buffer, vs. the 26 bytes I think I am telling it to write?

    My thanks in advance...


    ------------------------------
    Curt Gilker
    ------------------------------


  • 2.  RE: MQPUT is writing more data than BufferLength value

    Posted Wed January 13, 2021 10:24 PM
    You are correct that it should only be writing the BufferLength number of bytes.

    I think to help further we'd need to see your code to see if we could spot any issues. Are you able to post it here?

    Cheers,
    Morag

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



  • 3.  RE: MQPUT is writing more data than BufferLength value

    Posted Thu January 14, 2021 12:15 PM
    What language is your program? i.e. COBOL, C, C++, etc..  Can you post the code?  Are you sure that you didn't set/initialize the BufferLength to 10000?

    I haven't written COBOL code in a long time but here is some code I wrote that works:

    01 W01-MQM PIC X(48) VALUE 'MQA1'.
    01 W01-OBJECT PIC X(48) VALUE 'TEST1.Q'.
    01 W01-HCONN PIC S9(9) BINARY.
    01 W01-HOBJ PIC S9(9) BINARY.
    01 W01-COMPCODE PIC S9(9) BINARY.
    01 W01-REASON PIC S9(9) BINARY.
    01 W01-OUTPUT-BUFFER PIC X(1000) VALUE 'This is a test message 01.'.
    01 W01-OUTPUT-BUFFER-LENGTH PIC S9(9) BINARY VALUE 26.


        MOVE MQMT-DATAGRAM TO MQMD-MSGTYPE.
        MOVE MQCI-NONE TO MQMD-CORRELID.
        MOVE MQMI-NONE TO MQMD-MSGID.
        MOVE MQPER-NOT-PERSISTENT TO MQMD-PERSISTENCE.
        COMPUTE MQPMO-OPTIONS = MQPMO-NO-SYNCPOINT +
                                MQPMO-FAIL-IF-QUIESCING +
                                MQPMO-DEFAULT-CONTEXT.
        CALL 'MQPUT' USING W01-HCONN
                           W01-HOBJ
                           MQMD
                           MQPMO
                           W01-OUTPUT-BUFFER-LENGTH
                           W01-OUTPUT-BUFFER
                           W01-COMPCODE
                           W01-REASON.



    Regards,
    Roger Lacroix
    Capitalware Inc.