
Originally Posted by
arno
the FlatFileItemReader streams the data, so it shouldn't be the cause of the out-of-memory error. We need to know more to diagnose the error. Which ItemWriter are you using? You mentioned a queue, is it JMS? if so, is the JMS broker remote?
Thanks for your reply. I am extending the ItemWriter and writing the data into Gemfire Cache region. I hereby attached my code below for your reference. Please suggest and let me know i have to any changes in the Writer class to avoid this problem.
Code:
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.Region;
public class FeedToCache implements ItemWriter<FeedData> {
Cache cache;
Region cacheRegion;
public Region getCacheRegion() {
return cacheRegion;
}
public void setCacheRegion(Region cacheRegion) {
this.cacheRegion = cacheRegion;
try {
Thread.sleep(1200);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public void setCache(Cache cache) {
this.cache = cache;
setCacheRegion(cache.getRegion("cacheRegion"));
}
public void write(List<? extends FeedData> items) throws Exception {
for (FeedData item : items) {
if (item!= null)
if(item.getAccountNumber()!=null)
cacheRegion.put(item.getAccountNumber()+Math.random(),item);
}
}
}