Trying
Trying

Reputation: 14278

ReadOnly JMS message

Can somebody tell me Why the body and properties of a javax.jms.Message are made read-only after delivery in JMS spec. Is there any valid reason behind this. Thanks.

I will change the question a bit by reading Peter Lawrey comment. While i was reading one book it was mentioned as below:

> Why are both the body and properties made read-only after delivery? It
> allows the JMS provider more flexibility in implementing the Message
> object. For example, a JMS provider may choose to stream a
> BytesMessage or StreamMessage as it is read, rather than all at once.
> Another vendor may choose to keep properties or body data in an
> internal buffer so that it can be read directly without the need to
> make a copy, which is especially useful with multiple consumers on the
> same client.

here i couldn't understand the last line which says:

which is especially useful with multiple consumers on the same client

what does that means. Thanks in advance.

Upvotes: 0

Views: 2413

Answers (1)

Peter Lawrey
Peter Lawrey

Reputation: 533560

Received messages cannot be altered as this would imply other receivers of the message may or may not see those changes. It is assumed that changing a received message is more likely to be a mistake than useful.

Upvotes: 1

Related Questions