Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 516173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:42:15+00:00 2026-05-13T07:42:15+00:00

Here is the problem A user of an enterprise web application is performing a

  • 0

Here is the problem

A user of an enterprise web application is performing a task that results in a long (very long) database query (or other long processing intensive task)

Problems:

  • Request timeout – after a while the user may get a request timeout
  • Session timeout – if no session keeping methods are used, a session timeout can occur
  • Request thread lock
    • since the request thread is not returning, it may block new requrests (if reaches the pool limit)
    • In some application servers the server’s health status might trigger a forced restart of the node or application(due to a long running request thread)
  • If the user leaves the page:
    • the transaction is not canceled – resulting in useless processing no one will benefit from
    • the user can’t return to see the results after they complete
  • no progress indication – the user just waits for the page to refresh

There are several solutions I came up with, but I’m not sure I know which is better (in all aspects, peformance, best practice, elegance and maintainability) and I would like to know what is your recommended solution, and if there is a solution that I missed? (probably yes, and many)

The bad solution: use the request thread as a worker thread,save progress state in the session, have an AJAX call check the status (in the session) in another paralel request

The compromise solution: create your own thread pool, handle a monitoring thread, a worker thread and take care of clustering by syncronizing the states in either a distrubuted transactional cache or persistant storage. this releases the request, but creats threads the application server is not aware of, and won’t close in undeployment. Its up to you to shutdown threads in a clean way, and there is always a chance you will end up leaking something. This is not the J2EE way to do it either.

The J2EE solution: use JMS for the asynchronous task, this is what it’s ment for

the Spring solution: use Spring batch

What would you do / did in your projects? What other solutions you know? which of the ones I noted above is the winner in your opinion?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:42:15+00:00Added an answer on May 13, 2026 at 7:42 am

    I would do a combination of your so called “bad solution” and the “j2ee solution”:

    1. The original UI thread sends a asynchronous JMS message to the “backend” and returns.
    2. The backend receives the asynchronous request and processes it.
    3. When a result (or error) is reached in the backend, it is returned to the controller layer.
    4. The UI, still doing AJAX polling or using Bayeux/Cometed, receives and displays the result.

    The trick is to match the request / response pair. I would do it like this:

    1. Create a “AsyncManagerService” (AMS) that has SESSION, maybe even APPLICATION wide scope so all threads talk to the same instance.
    2. The AMS holds a map with an id as key and any object as value.
    3. When creating the request JMS message, generate a unique, random key and put it into the jmsCorrelationId of the message as well as into the map, with NULL as a value. Also pass that id to the UI.
    4. Let the UI thread poll the AMS with the previously generated id as long as the value in the map is NULL.
    5. When the result is ready, let your JMS receiver put it into the AMS’ map at the given id.
    6. Next time the UI thread polls the map, it will receive the answer and stop polling.

    This is clean and well abstracted from any concrete domain. A purely technical solution.

    Even if you don’t like polling, HTTP is stateless by design and I think this way polling only happens at well defined intervals.

    Anyway, I implemented a system with exactly this pattern and it runs just fine…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a strange problem here... I have an ASP.NET 3.5 application that has
I've got a problem here with an MSI deployment that I'm working on (using
Here's my problem: I have an application which uses sql server express 2005, and
Just a small SVN problem here. I setup my own SVN server Setting up
I'm having a bit of a problem here. We have 2 urls let me
I've got a Schroedinger's Cat type of problem here -- my program (actually the
This is in reference to the question previously asked The problem here is, each
Here's a problem I ran into recently. I have attributes strings of the form
Here's the problem, you include multiple assemblies and add 'using namespaceX' at the top
Here is a problem I've struggled with ever since I first started learning object-oriented

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.