Results 1 to 5 of 5

Thread: Threads or JMS or what else?

  1. #1
    Join Date
    Aug 2007
    Location
    London
    Posts
    6

    Question Threads or JMS or what else?

    Hi!

    I would like to implement concurrent stuff in Spring. A bit more in detail:

    A request comes in, depending on the request in the backend 0 to n parallel process must be started which all fill some data somewhere, until they are all done the request handler (spring based servlet) must block but when all are done it must continue.

    As I am old skool I would usually think of using Java Threads or some library based on that, but I am a bit unsafe, because I remember in the EJB specification threads were not "allowed", but I have no idea how that is in Spring..looks like it is "allowed".

    Currently I try to solve this problem with a JMS queue, but as all happens in one VM obviously this is an overload (at least 2 serialisations of the same object per request).

    Thanks! This is very important and quite urgent! Thanks again!

    CC
    I am an Object

  2. #2
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    Colin Yates
    SpringSource - http://www.springsource.com - Spring Training, Consulting, and Support - "From the Source"
    Please read http://www.springframework.org/documentation
    Co-Author of Expert Spring MVC + Web Flow.

  3. #3
    Join Date
    Nov 2004
    Location
    Hilversum - The Netherlands
    Posts
    1,054

    Default

    Quote Originally Posted by ConstantChange View Post
    Hi!

    I would like to implement concurrent stuff in Spring. A bit more in detail:

    A request comes in, depending on the request in the backend 0 to n parallel process must be started which all fill some data somewhere, until they are all done the request handler (spring based servlet) must block but when all are done it must continue.
    You can use the java.util.concurrent.Executor/java.util.concurrent.Future for that. But blocking in a servlet thread for a long period could lead to problems (like running out of threads in the webrequest pool).

    As I am old skool I would usually think of using Java Threads or some library based on that, but I am a bit unsafe, because I remember in the EJB specification threads were not "allowed", but I have no idea how that is in Spring..looks like it is "allowed".
    Custom threading solution are allowed in Spring. I have used it on various projects

    Currently I try to solve this problem with a JMS queue, but as all happens in one VM obviously this is an overload (at least 2 serialisations of the same object per request).
    You are looking for some distributed solution?

    Thanks! This is very important and quite urgent! Thanks again!
    You are welcome.

  4. #4
    Join Date
    Aug 2007
    Location
    London
    Posts
    6

    Default

    Thanks a lot!

    By the way, it is still open wether the solution is going to be a distributed one, so for now jms is ok. But I am pretty sure things will change and then I will go for threading...i'll just try to seperate functionalities well!!


    CHeers!
    CC
    I am an Object

  5. #5
    Join Date
    Nov 2004
    Location
    Hilversum - The Netherlands
    Posts
    1,054

    Default

    Quote Originally Posted by ConstantChange View Post
    Thanks a lot!

    By the way, it is still open wether the solution is going to be a distributed one, so for now jms is ok.
    You could also have a look at Terracotta. But I would extract the distribution mechanism from the implementation.

    I have just written an application that is distributed with Terracotta and thread related functionality is provided by Prometheus: a concurrency library I'm working on. Works like a dream

Posting Permissions

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