Hi Tim,

In continuation to my previous mail, I tried with increasing the array size
at the producer end, but still getting the same error.

Also, my producer is running till end, its the consumer which fails. The
same consumer never fails for Text/Map Messages of any length and of any
number of messages. So is there any other varibale, that needs to be set, or 
can it be something related to activemq.xml settings like some stack/heap
size i have to set.

Please let me know your inputs.

Thanks,
Manu

manua wrote:
> 
> Hi Tim,
> 
> I am getting the error, even when my file is just 65 bytes. Its also
> evident from the output (where I am capturing number of byte recieved). I
> have posted my output in the previous posts.
> 
> Also, if I want to transfer large files (image files of size 100K or
> more), than what should be the best approach. It will be very nice if you
> could share some code snippet, explaining this.
> 
> Thanks,
> Manu
> 
> Timothy Bish wrote:
>> 
>> On Fri, 2009-04-24 at 17:31 -0700, manua wrote:
>>> Hi Tim,
>>> 
>>> Thanks for your reply.
>>> 
>>> PLease find below the part of my code, which I am using for sending and
>>> recieving bytesmessages.
>>> 
>>> Code snippet from Producer.cpp
>>> 
>>> char Text[100];
>>> 
>>> ifstream inFile("abc.txt",ios::in | ios::binary);
>>> 
>>> int i=0;
>>> while(inFile>>Text[i])
>>> {
>>>         cout<createBytesMessage();
>>>                   message->setBodyBytes((unsigned char*)Text,(size_t)i);
>>> 
>>>  producer->send( message );
>>> 
>>>                 delete message;
>>> 
>>> 
>> 
>> Looks like bad things would happen if your file is more than 100 bytes
>> long.
>> 
>>> ================================================================
>>> 
>>> Code Snippet from Consumer side,
>>> 
>>> virtual void onMessage( const Message* message ){
>>> 
>>> static int count = 0;
>>> 
>>>         try
>>>         {
>>>             count++;
>>> const BytesMessage* bytesMessage =
>>>                 dynamic_cast< const BytesMessage* >( message );
>>> 
>>>                       char* tempCharArray=new
>>> char(bytesMessage->getBodyLength());
>>> BytesMessage* bytesMessage1 = bytesMessage->clone();
>>> bytesMessage1->reset();
>>> 
>>> ofstream outFile("abc_out.txt",ios::app | ios::binary);
>>>                 
>>> memcpy(tempCharArray,(char*)(bytesMessage1->getBodyBytes()),bytesMessage->getBodyLength());
>>> 
>>> outFile.write(tempCharArray,bytesMessage->getBodyLength());
>>>             if( clientAck ) {
>>>                 message->acknowledge();
>>>             }
>>> 
>>>             printf( "Message #%d Received: %s\n", count, tempCharArray
>>> );
>>>             printf( "\n no. of bytes =
>>> %d\n",bytesMessage->getBodyLength());
>>>                 delete []tempCharArray;
>>>                 tempCharArray=NULL;
>>> 
>>>         } catch (CMSException& e) {
>>>             e.printStackTrace();
>>>         }
>>>     }
>>> 
>>> ==================================================================
>>> 
>>> The same code was working fine for text and map messages.
>>> 
>>> Regarding platform, I am trying it on Amazon ec2 instances of medium
>>> size.
>>> 
>>> PLease let me know your inputs.
>>> 
>>> Thanks,
>>> Manu
>>> 
>>> Timothy Bish wrote:
>>> > 
>>> > On Wed, 2009-04-22 at 07:40 -0700, manua wrote:
>>> >> Hi All,
>>> >> 
>>> >> I am trying to send large bytes messages. From the producer end, I ma
>>> >> able
>>> >> to send the messages, but at the consumer end, after recieving some
>>> >> messages, I am getting Segmentation fault. 
>>> >> 
>>> >> Please find below the output, I recieved at the consumer end.
>>> >> 
>>> >> Kindly help me with this.
>>> > 
>>> > Can you create a simple test case that reproduces this issue?  If you
>>> > could do that and open a new Jira issue and attach the test that would
>>> > be helpful.  
>>> > 
>>> > Also provide any info about your Platform / OS / Compiler.
>>> > 
>>> > Regards
>>> > Tim.
>>> > 
>>> >> 
>>> >> =====================================================
>>> >> Starting the example:
>>> >> -----------------------------------------------------
>>> >> Press 'q' to quit
>>> >> Message #1 Received:
>>> >> fsfdfsgdfgdhdhdfghdhdhhhfgjjtrwertrtrtytryryfgchfghfghdfhdf              
>>> >>                                               
>>> >> hfdgdf
>>> >> 
>>> >>  no. of bytes = 65
>>> >> Message #2 Received:
>>> >> fsfdfsgdfgdhdhdfghdhdhhhfgjjtrwertrtrtytryryfgchfghfghdfhdf              
>>> >>                                               
>>> >> hfdgdf
>>> >> 
>>> >>  no. of bytes = 65
>>> >> Message #3 Received:
>>> >> fsfdfsgdfgdhdhdfghdhdhhhfgjjtrwertrtrtytryryfgchfghfghdfhdf              
>>> >>                                               
>>> >> hfdgdf~l
>>> > 
>>> > -- 
>>> > Tim Bish
>>> > http://fusesource.com
>>> > http://timbish.blogspot.com/
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> 
>> -- 
>> Tim Bish
>> http://fusesource.com
>> http://timbish.blogspot.com/
>> 
>> 
>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Segmentation-fault-while-sending-bytes-messages-tp23175494p23260347.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to