简体   繁体   中英

How to write to MQMessage: multiple Write calls, or StringBuilder?

I'm brand new to WebSphere MQ. I'm using IBM's .NET classes (IBM.WMQ) to put a request message and then get a response message. The MQMessage object has a number of Writexxx methods for various data types. I need to write a variety of different data elements to the request message. My question is, should I call the appropriate Write method for each individual data element, or should I build the whole thing with a StringBuilder and then call the MQMessage WriteString method once?

The write APIs are to try an help you write clearer code, but whoever converted the WMQ API to .Net is an idiot.

They wrote 20 different APIs instead of a "write" function with overloads. The write call has a few usable overloads.

They created one enum which has 100's if not thousands of options called MQC (MQ Constants). Have fun, but beware of transactions on WMQ, as there is a *cough small cost involved in using that functionality.

Now that I'm done with my rant, beware of the APIs that most of the apis have a limitation of an signed int in terms of size, only the write(byte[] array) and the writestring(string s) function take a large message. Also the .net api writes all strings UTF-16 as per .net's implementation which may affect you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM