Results 1 to 3 of 3

Thread: Approaches for multi-threading in an App Server?

  1. #1

    Default 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. #2
    Join Date
    Nov 2004
    Location
    Hilversum - The Netherlands
    Posts
    1,054

    Default Re: Approaches for multi-threading in an App Server?

    Quote 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).

  3. #3

    Default

    Thanks, Alarmnummer. I appreciate your detailed response.

Similar Threads

  1. Replies: 6
    Last Post: Sep 29th, 2005, 04:25 AM
  2. Replies: 1
    Last Post: Aug 23rd, 2005, 09:24 AM
  3. Replies: 3
    Last Post: Aug 16th, 2005, 12:39 PM
  4. Replies: 1
    Last Post: Nov 23rd, 2004, 08:19 PM
  5. Replies: 15
    Last Post: Aug 28th, 2004, 08:12 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
  •