activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Bish <tabish...@gmail.com>
Subject Re: problems reading a cms::BytesMessage.
Date Thu, 19 Feb 2009 19:24:21 GMT
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/




Mime
View raw message