*
The moose likes Struts and the fly likes Creating/calling thread within an Action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Creating/calling thread within an Action" Watch "Creating/calling thread within an Action" New topic
Author

Creating/calling thread within an Action

Makeshkumar Subramaniam
Greenhorn

Joined: Aug 09, 2008
Posts: 21

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.


cheers,
Makesh.

[URLyBird1.1.1 - > just started]
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8843
    
    7

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Makeshkumar Subramaniam
Greenhorn

Joined: Aug 09, 2008
Posts: 21

Thank you very much...That's was a nice advice ;-)
Makeshkumar Subramaniam
Greenhorn

Joined: Aug 09, 2008
Posts: 21

what if i use Quartz scheduler or Java Classloaders...won't they replace
JMS ???
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8843
    
    7

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"?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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
Makeshkumar Subramaniam
Greenhorn

Joined: Aug 09, 2008
Posts: 21

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 !!??)
Makeshkumar Subramaniam
Greenhorn

Joined: Aug 09, 2008
Posts: 21

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 !!??)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Creating/calling thread within an Action
 
Similar Threads
Value not being sent to DAO class from Struts form in JSP
Threads
Session problem in Struts and Tomcat
Creating datasource in WAS 5
Any pattens before access EJB when using Struts