• 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

Creating/calling thread within an Action

 
Greenhorn
Posts: 21
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends,

I'm developing a struts application that needs a thread to be (called) executed from an action class...now that my questions are :

1) is there any design that exist for creating or calling a Thread(or thread pool) from Action Class ??

2) what are all the issues that it may create if i do so???

Thanks in advance.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's a Bad Idea to create threads inside a container which itself manages threads:

If application components contain the same functionality
provided by J2EE system infrastructure, there are clashes and mis-management of the functionality.
For example, if enterprise beans were allowed to manage threads, the J2EE
platform could not manage the life cycle of the enterprise beans, and it could not properly manage transactions.



J2EE 1.4 Specification section 6.2.1 Programming Restrictions

What I usually do if I have a process which will take longer than the HTTP request-response cycle is create a long-running server process and dispatch requests to it via JMS. The long-running server then informs the user via email or some other means when the process is complete.
 
Makesh Subra
Greenhorn
Posts: 21
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much...That's was a nice advice ;-)
 
Makesh Subra
Greenhorn
Posts: 21
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what if i use Quartz scheduler or Java Classloaders...won't they replace
JMS ???
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have not used Quartz. How do you propose to integrate it?
JMS can provide fail-safe delivery of a message between two processes. I think Quartz may be one solution to implementing the second process (the first being your struts application) but not the fail-safe delivery of the request.
What do you propose to do with "Java Classloaders"?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Quartz is a job-scheduling system; I don't think there are any issues with guaranteeing job start/etc. messages, and it works outside of environments where JMS is (trivially) available, although I know you can add JMS to simple app servers.

I usually see it integrated through Spring, but doesn't need to be.

It's actually kinda nice, and I've found it a much simpler solution than JMS-based ones when you don't need the extra functionality JMS/etc. give you.

Kinda six-of-one in a lot of ways
 
Makesh Subra
Greenhorn
Posts: 21
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If i am right you are suggesting me to use Quartz instead of JMS...?! and i would like to tell you guys what actually my process is : I'm having an action class that submits a video to a video-server. Here, the problems are,
1) videos will be very larger
2) need to check if it get uploaded in the server, once uploading is finished status has to be updated with DB

----
but some of friends suggests to go on with threads...I feel guilty to use threads in action class.....(i really don't know what exactly will happen if i user threads !!??)
 
Makesh Subra
Greenhorn
Posts: 21
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If i am right you are suggesting me to use Quartz instead of JMS...?! and i would like to tell you guys what actually my process is : I'm having an action class that submits a video to a video-server. Here, the problems are,
1) videos will be very larger
2) need to check if it get uploaded in the server, once uploading is finished status has to be updated with DB

----
but some of friends suggests to go on with threads...I feel guilty to use threads in action class.....(i really don't know what exactly will happen if i user threads !!??)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic