Hello, I have upgraded to the new 2.2.5 version of activemq-cpp

but when I receive a bytesmessage within onMessage listener method, 
I get the following error:

<  836> 26 March 2009 05:34:55 PM[ERROR] - at [.\MyDispatcher.cpp        ] 
(MyDispatcher::onMessage   ) at line  110 ByteArrayInputStream::read - Buffer 
has not been initialized
        FILE: ..\src\main\decaf\io\ByteArrayInputStream.cpp, LINE: 117
        FILE: ..\src\main\decaf\io\ByteArrayInputStream.cpp, LINE: 146
        FILE: ..\src\main\decaf\io\DataInputStream.cpp, LINE: 171
        FILE: 
..\src\main\activemq\connector\openwire\commands\ActiveMQBytesMessage.cpp, 
LINE: 324
        FILE: .\MyDispatcher.cpp:MyDispatcher::onMessage, LINE: 99

the code is as follows:

void MyDispatcher::onMessage( const Message* message )
{
            const BytesMessage* b = dynamic_cast<const BytesMessage* >( message 
);
            if( b != NULL )
            {
                /* OLD HACK
                 * b->reset(); // this was my workaround hack using the 
previous version 2.2.4 (i made reset method const)
                 */
                try
                {
                    msg->readInt();
                }
                MY_CATCH_RETHROW(Exception)
                MY_CATCH_QL_EXCEPTION()
                MY_CATCH_STD_EXCEPTION()
                MY_CATCHALL_THROW(MyException)
            }
}

please let me know if you are able to figure out what i am doing wrong!


> From: hm14...@hotmail.com
> To: users@activemq.apache.org
> Subject: RE: problems reading a cms::BytesMessage.
> Date: Fri, 20 Feb 2009 09:33:09 +0100
> 
> 
> 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