Question

Here is what I need to do: Render PDFs using Apache's FOP on a server (preferably Windows). The jobs will come from a queue, but that's not too important.

I want to avoid warming up the JVM each time I need to render a job. FOP has a reference servlet that I could use with web requests, but I don't want to introduce Tomcat.

I have very rough Java skills (and would prefer to keep it that way) so, what's the easiest way to start a long-running Java program which can monitor a queue, and run FOP jobs, without the start-up overhead that happens with, say, a command line Java script? I would love to do this with Rhino, since I'm comfortable with JS, and already have a lot of the document processing logic in Rhino/JS. I definitely don't want to use a Java web server.

Was it helpful?

Solution

I think you only really have two options;

  1. A java "server", whether it be a web server or an RPC server. We use thrift to communicate with a long-running java service who's only purpose is to generate PDFs. We pre-load FOP at start-up and keep the library "hot" for each request. A web service would be just as good.

  2. A java daemon which listens to the queue you mentioned, generates the PDF (putting it in the tmp folder, maybe?) and returns a notification of completion and location on another queue (this is actually how we work for generating long-running financial reports with > 300 pages).

You could use whatever language you want; if Rhino can communicate to Java/FOP directly you shouldn't have a problem. We've used Jython and Scala for various projects on top of Java.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top