Preamble
In the IBM MQQueue class there is a method called get() which retrieves a message from a queue. This method has a number of overloaded versions including one which allows an MQGetMessageOptions object to be supplied as well as a maximum message length. By using this combination, a portion of the message may be retrieved (destructively or with a browse operation).
If the message actually on the queue is bigger than the maximum length allowed, an MQException is thrown. This exception specifies that a trunctated message was accepted.
Discussion
In Java, the cost of throwing an exception is expensive. If one wishes to browse a queue and examine, say, the first 10 bytes of each message, an exception will have to be handled for each message. This feels like a poor performer.
The returned message already contains how many bytes are in the message retrieved and how many bytes are in the original message. I think I would like to have seen NO exception thrown and leave it to the consumer of the message to determine if the complete or partial message was returned.
[ This Message was edited by: kolban on 2001-08-29 21:01 ]