• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multiple threads to be created and require use of database access

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am a newbie to spring and having trouble in implementing a requirement. Let me explain my requirement.
We have a hierarchial architecture where there is a parent server that controls access to downstream m/c.
The server is supposed to periodically collect the data from the downstream machines and store it in the database. So an approach is to spawn multiple threads (kind of executor interface) to collect the data and store the data in the database. Where we can fine tune the number of thread as per the load on the system.
Now the server is running the spring software and the multiple threads need access to the database.
How shall I do it in spring?
As far as I understood it is not recommended to use multiple threads and better to use TaskExecutor. The task has to be created dynamically and will probably be run on a separate thread. How shall this dynamically created task gain access to DAO(basically entity manager). If I pass a reference injected into my task creation bean can that be then passed as an argument to constructor, remember the bean may go out of scope after this.
These are some of the questions I am struggling with. Please tell me what would be the best way to implement such a requirement.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic