Results 1 to 5 of 5
  1. #1
    Piz
    Piz is offline Member
    Join Date
    Nov 2016
    Posts
    2
    Rep Power
    0

    Default server polling to know when a huge file is ready

    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.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: server polling to know when a huge file is ready

    Have the file code inside a separate thread. You could declare a method which the file gen code calls once the task is
    complete. This would avoid any requirement for polling as you would simply wait for a completion event in
    the form of the aforementioned method call. Note: Threads can introduce subtle errors in code if not done properly.

    Regards,
    Jim
    Last edited by jim829; 11-28-2016 at 03:15 PM.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,989
    Rep Power
    8

    Default Re: server polling to know when a huge file is ready

    Don't use Threads in an EJB container. Just because you can, doesn't mean you should.

    Use Asynchronous EJB's: Asynchronous Method Invocation - The Java EE 6 Tutorial
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: server polling to know when a huge file is ready

    I stand corrected!

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  5. #5
    Piz
    Piz is offline Member
    Join Date
    Nov 2016
    Posts
    2
    Rep Power
    0

    Default Re: server polling to know when a huge file is ready

    Thanks for our answers. I'll read the ejb async guide.

    I'll let you know! :)

Similar Threads

  1. Replies: 1
    Last Post: 06-27-2013, 09:46 PM
  2. Replies: 9
    Last Post: 05-28-2011, 09:13 PM
  3. Replies: 15
    Last Post: 04-12-2011, 03:42 PM
  4. Issues with parsing huge file
    By aneuryzma in forum New To Java
    Replies: 2
    Last Post: 03-29-2011, 03:02 AM
  5. display huge size file in jtextarea
    By tskarthic in forum AWT / Swing
    Replies: 1
    Last Post: 03-21-2009, 06:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •