Hi Tim,

 

thanks for your answer.

 

in fact, as a workaround I did clone the message, but even if I deleted the 
cloned message at the end of processing

, memory usage increased very rapidly. about 200 MB in 30 seconds when 
receiving a lot of message from a topic.

that's why i don't want to clone the message.

 

i think message should be passed already in read-only status and with the input 
stream reset.

 

as a workaround, and only for compiling client code, i modified the reset() 
prototype to make it const. 

 

it works now. i will try to read impl library code to verify if there is any 
reason why the message is not passed

ready to be read.

 

thanks again,

 

Regards,

 

Eduardo

 

 
> Subject: Re: problems reading a cms::BytesMessage.
> From: tabish...@gmail.com
> To: users@activemq.apache.org
> Date: Thu, 19 Feb 2009 14:24:21 -0500
> 
> On Thu, 2009-02-19 at 19:06 +0100, Eduardo Montoya wrote:
> > Hello,
> > 
> > I have some problems when reading a cms::BytesMessage.
> > 
> > first of all, my client code looks like:
> > 
> > void MyMessageListener::onMessage( const Message* message )
> > {
> > const BytesMessage* b = dynamic_cast<const BytesMessage*>( message );
> > if (b != NULL)
> > {
> > std::size_t len = b->getBodyLength(); // this line compiles and works.
> > 
> > int i = b->readInt(); // this compiles but gives me an exception.
> 
> Its possible that there's either no data in the message or we have a bug
> in setting the message into readonly mode correctly. 
> 
> > // message is in write-only mode ....
> > 
> > // then i tried to execute the following line to set the input stream to 
> > read-only
> > b->reset(); // this line does not compile.
> 
> You can't do this with async since the message is const here, you don't
> own the message that's contained in the onMessage callback, if you
> wanted to reset the message you'd need to call Message::clone to get a
> new instance of it that's yours to alter or store for later use. This
> might be a workaround if for you if we do in fact have a bug in the
> code.
> 
> > 
> > // VC++ 2008 express edition compiler says:
> > // error C2662: 'cms::BytesMessage::reset' : cannot convert 'this' pointer 
> > from 'const
> > // cms::BytesMessage' to 'cms::BytesMessage &'
> > 
> > }
> > }
> > 
> > i found the following issue:
> > 
> > https://issues.apache.org/activemq/browse/AMQCPP-143
> > 
> > but it talks only about readXXX methods.
> > not about reset method.
> > 
> > could anyone give me any advice to resolve this problem?
> > 
> > thank a lot for all your replies.
> > 
> 
> If you can create a sample test case to reproduce this problem and
> attach it to a new Jira issue we can look into what is going on and
> hopefully get it fixed in the next release.
> 
> > Kind Regards,
> > 
> > Eduardo
> > 
> 
> Regards
> Tim.
> 
> 
> -- 
> Tim Bish
> http://fusesource.com
> http://timbish.blogspot.com/
> 
> 
> 

Reply via email to