Monday, 15 February 2010

.net - Why do I get MQRC_NO_MSG_AVAILABLE? -



.net - Why do I get MQRC_NO_MSG_AVAILABLE? -

i have next code :

mqqueuemanager mqm = null; mqqueue mqqueue = null; seek { mqm = new mqqueuemanager("swiftqm", "swiftchannel", "localhost"); mqqueue = mqm.accessqueue("swiftq", mqc.mqoo_input_as_q_def | mqc.mqoo_fail_if_quiescing); mqmessage mqmsg = new mqmessage(); mqgetmessageoptions mqgetmsgopts = new mqgetmessageoptions(); mqgetmsgopts.options |= mqc.mqgmo_syncpoint; mqqueue.get(mqmsg, mqgetmsgopts); string s1 = ""; if (mqmsg.format.compareto(mqc.mqfmt_string) == 0) s1 = mqmsg.readstring(mqmsg.messagelength); string s2 = ""; mqqueue.get(mqmsg, mqgetmsgopts); if (mqmsg.format.compareto(mqc.mqfmt_string) == 0) s2 = mqmsg.readstring(mqmsg.messagelength); } { if (mqqueue != null) mqqueue.close(); if (mqm != null) mqm.disconnect(); if (mqm != null) mqm.close(); }

though queue has many messages, sec mqqueue.get gets "mqrc_no_msg_available" exception. there alternative missing?

yes, have mqmsg = new mqmessage(); before making sec get call. reason mqmessage object gets initialized incoming message (headers , message body) during get call. illustration messageid of incoming message set mqmessage.messageid property.

as can notice sec get beingness called mqmessage object initialized in first get call. means sec phone call looking message message id have received in first call. message had already been received in first phone call itself. hence sec phone call fails mqrc_no_msg_available reason code.

also using mqgmo_syncpoint option. there no commit beingness called in code. alternative receiving messages in local transaction. if don't intend receive message under transaction, have remove alternative else mqm.commit. if commit not called messages redelivered when connection made again.

.net websphere-mq

No comments:

Post a Comment