Announcement Announcement Module
Collapse
No announcement yet.
Can I use Spring-Batch for this? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can I use Spring-Batch for this?

    Hi all,

    I'm trying to rewrite my old daemon-server as a Spring application. (Wohoo!)

    Anyways it goes as follows:

    The main daemon process starts by loading a number of JobQueue entities from Hibernate (works fine). At the moment, there are six entities.

    For each JobQueue entity, the main daemon process instantiates a Timer with an associated class implementing TimerTask, which runs once a minute. When each thread's TimerTask runs, it looks into the Spring application context (Hibernate) and does what it needs to do. All threads can run simultaneously.

    As a minimum, each thread needs to know the PK of the JobQueue it is related to. Now, I pass this on to each instance as a parameter upon instantiation.

    Can I dynamically create these daemon threads in Spring-Batch and register each thread in the Spring application context, or how should I do this?

    Best regards,

    Morten

  • #2
    "Registering threads with an application context" isn't really a Spring idiom, so I wonder what you had in mind there? Anyway, I would say that scheduling and background threads are not a concern of Spring Batch per se, but they are Spring Framework concerns (especially now that Spring 3.0 has native declarative scheduling). Spring Batch would come in when you wanted to implement the tasks on your threads, and you didn't say much about that, so it's hard to say if it's a good fit or not.

    Comment


    • #3
      Originally posted by Dave Syer View Post
      "Registering threads with an application context" isn't really a Spring idiom, so I wonder what you had in mind there? Anyway, I would say that scheduling and background threads are not a concern of Spring Batch per se, but they are Spring Framework concerns (especially now that Spring 3.0 has native declarative scheduling). Spring Batch would come in when you wanted to implement the tasks on your threads, and you didn't say much about that, so it's hard to say if it's a good fit or not.
      Hm.... Thats also what I have mostly concluded during the last days trial and error on my coding:

      I cannot set up my threads programatically (based on the actual entities from Hibernate) and have them registered in the Spring application context upon container startup.

      It would be a nice feature though, if Spring would allow for a <foreach> syntax around my bean declaration in applicationContext.xml. The <foreach> should theen loop over an entity bean list.

      Comment

      Working...
      X