ibm-messaging / mq-golang

Calling IBM MQ from Go applications
Apache License 2.0
167 stars 60 forks source link

After using MQGMO_ACCEPT_TRUNCATED_MSG option getting message with data length 0 #205

Closed ssuryava-tibco closed 8 months ago

ssuryava-tibco commented 1 year ago

Hi Team,

I was getting error MQCC_WARNING [1] MQRC = MQRC_TRUNCATED_MSG_FAILED [2080] for message size grater than buffer size. So I added MQGMO_ACCEPT_TRUNCATED_MSG to gmo.Options

But now I am getting a message with no data and data length is 0

gmo options are used as below

    gmo.Options = ibmmq.MQGMO_NO_SYNCPOINT
gmo.Options |= ibmmq.MQGMO_PROPERTIES_AS_Q_DEF
gmo.Options |= ibmmq.MQGMO_ACCEPT_TRUNCATED_MSG

if gmoConvrt := context.GetInput("gmoConvert"); gmoConvrt != nil && gmoConvrt.(bool) {
    gmo.Options |= ibmmq.MQGMO_CONVERT
}

@ibmmqmet Could you please suggest.

Thanks, Sneha Suryawanshi

ibmmqmet commented 1 year ago

Not enough information here.

What buffer are you passing into the Get (or GetSlice) function? What is telling you that the message length is 0? Remember that there will be a returned error object, because the MQRC is considered a warning. So you need to take that into account when checking the returned values.

ssuryava-tibco commented 1 year ago

Hi @ibmmqmet,

We are taking buffer size as input from user, and default buffer as buffer = make([]byte, int32(50000)) in Get function. The Get call is giving warning as below Get activity got this warning on the get api call [MQGET: MQCC = MQCC_WARNING [1] MQRC = MQRC_TRUNCATED_MSG_ACCEPTED [2079]]

The function is bufLen, err := queue.Get(getmqmd, gmo, buffer) where it is returning 0 as bufLen

I can see MQMD properties for the output message, but message is empty with no data

Below is the debug log from Get app

GMO option is &{1 69 1000 0 0 3 32 32 32 32 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] -1 0 {0 <nil>}} and gmo op is 69
2023-11-06T07:28:23.140Z WARN [ibmmq-get] - Get activity got this warning on the get api call [MQGET: MQCC = MQCC_WARNING [1] MQRC = MQRC_TRUNCATED_MSG_ACCEPTED [2079]]
2023-11-06T07:28:23.140Z DEBUG [ibmmq-get] - Get activity got [0] bytes from queue [Q2]
this is bufLen 0
this is msgbuff []
2023-11-06T07:28:23.140Z DEBUG [ibmmq-get] - Get created MQMD output map: [map[AccountingToken:HgEFFQAAAKWeuyoa/kBAAbs4TvQBAAAAAAAAwE/ILws= ApplIdentityData: ApplOriginData: BackoutCount:0 CodedCharSetId:819 CorrelId:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA Encoding:546 Format: MsgId:QU1RIFFNMjEgICAgICAgIGC09WQCMSFA MsgType:Datagram Priority:0 PutApplName:APP - IBM MQ PutApplType:6 PutDate:20231106 PutTime:07225184 ReplyToQ: ReplyToQmgr:QM21 UserIdentifier:Administrato]]
2023-11-06T07:28:23.141Z DEBUG [ibmmq-get] - %!a(string=Get) got basic string message with content []
2023-11-06T07:28:23.141Z DEBUG [ibmmq-get] - Get pushed existing queue manager for connection name [MQConn]
2023-11-06T07:28:23.141Z DEBUG [ibm-mq.activity.get] - Task[Get] - Set Output: MQMD = map[AccountingToken:HgEFFQAAAKWeuyoa/kBAAbs4TvQBAAAAAAAAwE/ILws= ApplIdentityData: ApplOriginData: BackoutCount:0 CodedCharSetId:819 CorrelId:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA Encoding:546 Format: MsgId:QU1RIFFNMjEgICAgICAgIGC09WQCMSFA MsgType:Datagram Priority:0 PutApplName:APP- IBM MQ PutApplType:6 PutDate:20231106 PutTime:07225184 ReplyToQ: ReplyToQmgr:QM21 UserIdentifier:Administrato]
2023-11-06T07:28:23.141Z DEBUG [ibm-mq.activity.get] - Task[Get] - Set Output: Message = map[String:]
2023-11-06T07:28:23.141Z DEBUG [ibm-mq.activity.get] - Task[Get] - Set Output: MessageProperties = map[]
2023-11-06T07:28:23.141Z DEBUG [ibmmq-get] - Get IBM MQ get eval end

Please suggest.

Thanks, Sneha Suryawanshi

ibmmqmet commented 1 year ago

you've said you have a large DEFAULT buffer, but not actually shown what the real input buffer is. The only way I can get a zero length returned buffer is to supply an empty buffer on input.

ssuryava-tibco commented 1 year ago

Hi @ibmmqmet ,

If I am giving buffer as buffer = make([]byte, 50000) and message to be get is more in size, say 51000 bytes.

In this scenario, if MQGMO_ACCEPT_TRUNCATED_MSG GMO option is used, then ideally the data should get truncate and buffer should get filled with 50000 bytes right?

In my case I am getting GET call output as 0 bytes. Data truncation should work with the GMO option MQGMO_ACCEPT_TRUNCATED_MSG Somehow it is not happening.

ibmmqmet commented 11 months ago

Can't think why it's not behaving as expected for you. It's doing the correct things for me. Perhaps try modifying the mqi.go source file to print the buffer just before the call to MQGET in the getInternal function.