views:

59

answers:

1

Hello

I need to generate a report with java (exporting data from oracle) that can take several minutes, by the amount of data involved, so when I submit my form the screen freezes until it ends.

How can I generate the report in a background process, so that the user can continue browsing?

JMS? How can i do this with JMS? (Any example or explanation is welcome)

Is there another way? What would be the best option according to the J2EE specification?

A: 

Yes, JMS might be an option. You simply send a message to a queue, and a Message Driven Bean -- a special kind of EJB -- will then receive and process the message. The message acts in this case like a command. You can use JMS without Message Driven Bean though, but it's a bit more complicated.

If you are in a EJB 3.1 environment, you could give a try to asynchronous EJB.

Otherwise, while it's not recommended by the spec, you could start a thread in the web container. Either you start one thread per job, or you could start/stop one background thread in a ServletContextListener, which processes commands that you store, say, in a table in a database.

Using asynchronous jobs is superficially very easy, but for production you will need to think about how to manage error, monitor progress, retry failed job, ensure that no two same job are run at the same time, etc. Each approach has its own strength and weakness. Pay also attention to the strategy you need for the transactions (JMS is transacted, I don't know exactly for async EJB 3.1., and custom thread and database table can be transacted if do things correctly with JDBC transaction or UserTransaction).

Hope it helps.

ewernli
Hey thanks for the answer, and sorry about my late response, i'll try that.but is there anyway to consult the state of the asynchronous process ??
ErVeY