Have you had a look at StreamWriteFilter/FileRegionFilter? I think those are the best for writing large files. Just put the one you prefer AFTER your ProtocolCodecFilter in the filter chain. Once you've done that you can write InputStream/FileRegion objects using IoSession.write(). I think FileRegionFilter only exists in MINA 2.0. MINA 1.x includes the StreamWriteFilter.

HTH

/Niklas

Peter skrev:
Hi

I'm brand new to MINA. I've come up with a protocol which includes file 
attachments. I'm extending the CumulativeProtocolDecoder as per the 
ImageDecoder example in the documentation. It works fine for small files but I 
am unable to send a 1.5MB file, it never gets further than around 320 - 330k 
(varies every time). Without going into too much further detail, here are some 
log excerpts from my application. I log every time I enter doDecode and return 
false in doDecode():

2008-05-30 16:18:05,903 DEBUG [org.apache.mina.filter.executor.ExecutorFilter] 
- Launching thread for /192.168.1.211:60859
2008-05-30 16:18:05,906 DEBUG [protocol.RequestDecoder] - receiving new 
request, remaining bytes: 1024
2008-05-30 16:18:05,910 DEBUG [protocol.RequestDecoder] - received command 
DEPLOY
2008-05-30 16:18:05,911 WARN [protocol.RequestDecoder] - not enough data 
remaining [1018] we need [1456607]
2008-05-30 16:18:05,912 DEBUG [protocol.RequestDecoder] - receiving new 
request, remaining bytes: 3066
2008-05-30 16:18:05,912 WARN [protocol.RequestDecoder] - on returning call, 
still not enough data remaining [3066] we need [1456607]
.
.
.
2008-05-30 16:18:05,962 WARN [protocol.RequestDecoder] - on returning call, 
still not enough data remaining [308058] we need [1456607]
2008-05-30 16:18:05,962 DEBUG [protocol.RequestDecoder] - receiving new 
request, remaining bytes: 311970
2008-05-30 16:18:05,962 WARN [protocol.RequestDecoder] - on returning call, 
still not enough data remaining [311970] we need [1456607]
2008-05-30 16:18:05,963 DEBUG [protocol.RequestDecoder] - receiving new 
request, remaining bytes: 327126
2008-05-30 16:18:05,963 WARN [protocol.RequestDecoder] - on returning call, 
still not enough data remaining [327126] we need [1456607]
2008-05-30 16:18:05,963 DEBUG [org.apache.mina.filter.executor.ExecutorFilter] 
- Exiting since queue is empty for /192.168.1.211:60859

I was wondering if MINA is suited for this kind of application and if there's 
any inherit size limit in CumulativeProtocolDecoder. I run this with 1GB heap 
size and 256M max direct buffer size. Does anyone have any insights?

Thanks
Peter

Reply via email to