Announcement Announcement Module
Collapse
No announcement yet.
Threads or JMS or what else? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    Have you read http://static.springframework.org/sp...cheduling.html

    Comment


    • #3
      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.

      Comment


      • #4
        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

        Comment


        • #5
          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

          Comment

          Working...
          X