• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

server polling to know when a huge file is ready

 
Nicola Pizzipe
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ciao all,

i'm new in this forum. I've some years of experience in java but i'm not expert in j2ee.

I developed a @Stateless EJB that creates a huge file in file system. After that, when the file is ready, i have to send it via mail.
The EJB has transaction management as BEAN, with explicit begin/commit transaction to avoid server timeout.

But if i call this EJB from the client, the client remains freezed until the file is complete

I would like to start file generation and make the client free immediately. Then, i would like to ask server (polling) to know when the file is ready, then send it via mail.

Could you tell me the best way to resolve this problem?

Thanks a lot.
 
Rob Spoor
Sheriff
Pie
Posts: 20745
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

The client waits until the method it calls is ready, so you have to make sure that method finishes early. One easy way to do this is by calling an @Asynchronous method and let that method do the hard work in some other thread.

Note that if you call a method of the same class, that will ignore any annotations. You'd either have to use another helper bean, or use SessionContext and its getBusinessObject method to get a reference to the same object but with all the JEE annotation-based additions enabled.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic