Recently, while doing some work with C # and ActiveMQ (via Apache.NMS libraries), I came across the following property on ActiveMQBytesMessage
public new byte[] Content
{
get
{
byte[] buffer = (byte[]) null;
this.InitializeReading();
if (this.length != 0)
{
buffer = new byte[this.length];
this.dataIn.Read(buffer, 0, buffer.Length);
}
return buffer;
}
..(setter omitted)
}
The method InitialiseReadinghandled the connection and data streams from the active MQ in the field .dataIn. The problem, however, was that IT DID THIS EVERYTIME . And once this data has been read, it can never be read again, and the dataIn field was zero and reset. Therefore, simply by observing the property and observing it again, you have lost the data. This was made for some very strange errors, such as:
byte [] myBytes = new byte[msg.Content.Length];
msg.Content.CopyTo(myBytes,0);
or when you were debugging and you were stuck in the watch variable, or accidentally hovering over a property.
.