Announcement Announcement Module
Collapse
No announcement yet.
Approaches for multi-threading in an App Server? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Approaches for multi-threading in an App Server?

    Hello. I'm building a Spring MVC+Hibernate web application using WebLogic and have a need for multi-threaded processing (i.e. process a JMS message after persisting the contents).

    What is the recommended approach for this? I've considered the following so far:
    • Create a thread (or pool of threads)
      Trigger some Spring scheduled process (or have it run frequently)
      Start up another Servlet and communicate with that from the Spring MVC app
    Any ideas would be appreciated. Thanks.

  • #2
    Re: Approaches for multi-threading in an App Server?

    Originally posted by biguniverse
    Hello. I'm building a Spring MVC+Hibernate web application using WebLogic and have a need for multi-threaded processing (i.e. process a JMS message after persisting the contents).

    What is the recommended approach for this? I've considered the following so far:
    • Create a thread (or pool of threads)
    • This could be a solution. If you use the new concurrency library of java 5 (or the backport for java 1.4) you can use an executor. I would suggest a ThreadPoolExecutor that uses a threadpool (one thread would be sufficient) the process the jobs. Now you only have to create a job and drop it in the Executor. With a ThreadPoolExecutor you have total control on the number of threads that are running (so no more uncontrollable new Thread(someRunnable).start() in your system).

      You even have control on how many jobs are stored before they are executed if you use a bounded BlockingQueue. The call that gives the runnable to the executor blocks untill there is space in the queue.

      Trigger some Spring scheduled process (or have it run frequently)
      This also would be a solution. You can store all requests in a Queue and periodically empty the queue and process all requests. You can use a Timer or the ScheduledExectutor of java 5 (Quartz would also be a solution but I think it is to heavy for this problem).

      Personally I would use the first solution if there is no reason the process jobs in a batch.

      Start up another Servlet and communicate with that from the Spring MVC app
    Yuk.

    [edit]
    If you are using JMS, it think it would be better to use a complete JMS solution so you can make use of the services it provides (for example transaction support).

    Comment


    • #3
      Thanks, Alarmnummer. I appreciate your detailed response.

      Comment

      Working...
      X