Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
too much delay running report
electra
Hi all.
I have integrated BIRT in my java web application and I'm trying to run and show a report using a servlet.
The problem is that when I run the report using the "preview" button on the designer screen, the report is rendered in few second but when I try to do the same thing calling the report engine from the servlet I had a big delay for each execution.
The delay is done during the execution of the task.run(); statement in this part of code
Iterator<String> iterator = parametersMap.keySet().iterator();
while(iterator.hasNext()){
String key=iterator.next();
Object value=parametersMap.get(key);
task.setParameterValue(key, value);
}
task.validateParameters();
RenderOption options = new RenderOption();
options.setOutputFormat(outputFormat);
options.setOutputStream(baos);
task.setRenderOption(options);
task.getAppContext().put(IConnectionFactory.CLOSE_PASS_IN_CONNECTION , Boolean.TRUE);
long init=System.nanoTime()/1000;
task.run();
long end=System.nanoTime()/1000;
System.out.println(end-init);
task.close();
return baos;
Can anyone explain me why (what happen during the task.run?) and tell me if something could help me to decrease this delay?
Thanks for help!
Find more posts tagged with
Comments
JasonW
Remember that when you run in the designer all data is not returned unless you change the preferences. Are you only starting the platform once? That is generally what takes the most time on small reports.
Jason
electra
Thanks for you replay, Jason.
The platform is started once, only for the first request.
Here my doGet method
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
//get report name and launch the engine
resp.setContentType( "application/pdf" );
resp.setHeader ("Content-Disposition","inline; filename=test.pdf");
String reportName = req.getParameter("ReportName");
ServletContext sc = req.getSession().getServletContext();
this.birtReportEngine = BrowserBirtEngine.getBirtEngine(sc);
IReportRunnable design;
try
{
//Open report design
design = birtReportEngine.openReportDesign( sc.getRealPath("/Reports")+"/"+reportName );
//create task to run and render report
IRunAndRenderTask task = birtReportEngine.createRunAndRenderTask( design );
task.getAppContext().put("BIRT_VIEWER_HTTPSERVLET_REQUEST", req );
//set output options
PDFRenderOption options = new PDFRenderOption();
options.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_PDF);
resp.setHeader( "Content-Disposition", "inline; filename=\"test.pdf\"" );
options.setOutputStream(resp.getOutputStream());
task.setRenderOption(options);
//run report
task.run();
task.close();
}catch (Exception e){
e.printStackTrace();
throw new ServletException( e );
}
}
The getBirtEngine(sc) method starts the platform.
The problem is in the task.run() method: this takes a long time for each request. Do you think is possible to optimize the execution?
Many thanks.
JasonW
How complex is the report and how many rows of data are you processing?
Jason
electra
Ops...
I'm sorry, in my servlet the shutdown for the platform is doing every times. Now I've corrected the code to start the platform only once and everithing works fine.
Many thanks for your replay.