addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1light-bulblinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

RE: [ljc] Pausing execution in a web app

From: Jon H.
Sent on: Wednesday, July 3, 2013 10:28 PM
Thanks very much that is exactly what I need!

In response to the 2 questions, Dr. Warburton, the client sends us a message via JMS and we respond immediately, this is too fast for them to deal with. They should really be delaying sending on their side (especially as with JMS you can put a consumption delay on the message at the producer end) - this is basically an oversight on their part and we are accommodating for them temporarily.

Alex, (3) is better (I think) because although it hogs resources it does not block them as (4) does. Good point though - although you should be cautious about creating threads in wep apps, since the container should manage them and you could end up with rogue threads, it is probably less critical to briefly pause them. There are the considerations of the general principal of being as lightweight as possible and the fact that there could be many requests that cumumlatively cause resource overload, though apart from that I suppose (4) could be ok, if used in a non-intensive system.

Regards,
Jon


From: [address removed]
To: [address removed]
Subject: Re: [ljc] Pausing execution in a web app
Date: Wed, 3 Jul[masked]:20:43 -0400

Hi Jon,

From the JEE6 tutorial:

The following code sets a programmatic timer that will expire in 1 minute (6,000 milliseconds):

long duration = 6000;
Timer timer =
  timerService.createSingleActionTimer(duration, new TimerConfig());


Regards, 


Ged

On 3 July[masked]:45, Jon Hatfield <[address removed]> wrote:
Hi all,

I just had to pause execution for 5 seconds in an EJB, running on JBoss. Here are the various solutions I thought of, in order of what I think is best to worst:

1. Start a cached thread pool using the servlet context listener (to disassociate the HTTP request threads with creating new threads - cached in case graceful shutdown of threads fails) and tap into it to schedule a delayed action.
2. Create a polling service to trigger the process when appropriate.
3. Compare to <current time in millis + 5000ms> in a loop, which is pretty intensive.
4. Use Thread.sleep, which you should never really do in a web app.

I temporarily went with 3, but only for a UAT environment, as no time for 1 or 2... could anyone with more web-based multi-threading advise, as I will need a better solution, especially for production?

Thanks and regards,
Jon




--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Jon Hatfield ([address removed]) from LJC - London Java Community.
To learn more about Jon Hatfield, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Ged Byrne ([address removed]) from LJC - London Java Community.
To learn more about Ged Byrne, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]

Our Sponsors

  • Our Blog

    Read the latest news from the LJC

  • RecWorks Ltd

    Fixing Tech Recruitment using the Power of Community

  • jClarity

    Java/JVM Performance Analysis Tools & mentoring for Java related matters

  • LJC Aggrity

    Our LJC Aggrity site contains blog posts from our members

  • LJC Book Club

    Our Book club with book reviews from our members

  • Devoxx UK

    Java Community Conference in collaboration with the LJC, 8-10th June 16

  • SkillsMatter

    "Host, help organise, promote, film many of our meetings."

  • IBM

    Build Enterprise-grade apps at start-up speed.

  • New Relic

    New Relic makes sense of billions of metrics a day in real time.

  • Hazelcast

    Hazelcast is the leader in operating in-memory computing.

  • Java.Net

    We are an official Java User Group recognised by Oracle's JUG program

  • JRebel

    Free 3 month J-Rebel license.

  • O'Reilly

    40% discount on printed books and 50% on e-books.

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy