On 04/11/2012 08:08, Chris Barrow wrote:
> Hi Nigel,
>
> I would vote for getType returning an enum of {BYTES, MAP, OBJECT, STREAM, TEXT} as I mentioned in the thread below,
> because it makes it easier to write generic code to handle any message (using a switch statement), and getBody. I do not
> believe isBodyAssignableTo is worth including.
Thanks for raising this here.
When you mentioned this to me directly I gave the following response, which I'll repeat here (in case people don't
notice it near the end of your email:
Your proposal would offer a way of finding out the message type (BytesMessage, ObjectMessage etc) without using instanceof.
isBodyAssignableTo would do something slightly different as it also tell you whether the body of an ObjectMessage
could be cast to a specified type. It is intended to match the behaviour of getBody, which not only allows to, say,
extract the String from a TextMessage but also extract the body of an ObjectMessage *and* cast it to the specified type.
More views, please, on both Message.getBody() and Message.isBodyAssignableTo().
Draft API docs here:
http://jms-spec.java.net/2.0-SNAPSHOT/apidocs/javax/jms/Message.html#getBody%28java.lang.Class%29
Nigel