Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / January 2005

Tip: Looking for answers? Try searching our database.

newbie J2EE threading question

Thread view: 
anon - 06 Jan 2005 23:15 GMT
I am new to J2EE, I just want a quick idea of what is possible and where to
start looking.

My app combines a remote UI and some fairly heavy duty file processing. I
don't want to do the processing in the main thread of the session bean that
the UI is talking to, because that would kill it for a while.

In a traditional environment (eg an MFC app) I would use a separate thread
to do the processing. What is the J2EE way to do this?

I thought of using a message driven bean to do the processing. The session
bean can send it a message to do the processing, and maybe then poll for
completion. Is that a typical way of doing it? Does the message driven bean
always get a separate thread, and how can this be controlled?
EricF - 07 Jan 2005 05:22 GMT
>I am new to J2EE, I just want a quick idea of what is possible and where to
>start looking.
[quoted text clipped - 10 lines]
>completion. Is that a typical way of doing it? Does the message driven bean
>always get a separate thread, and how can this be controlled?

You might want to get a better understanding of EJB and some of the
restrictions and best practices.

Take a look here:

 http://www.theserverside.com/discussions/thread.tss?thread_id=28980

The container handles threading for you and session beans should not be doing
threading.

Session beans scale well because the container can have multiple instances of
a session bean. So in general, a session bean should not need to start a
thread.

One needs to be very careful if a bean is doing any writing to a file:
     
 http://weblogs.java.net/blog/simongbrown/archive/2003/10/file_access_in.html

Offloading processing to a MDB can be quite useful - but polling would negate
delegating any work - and I'm not sure how one would do that polling unless
the MDB write to a database.

It doesn't sound like EJB may be the best solution to your problem - but
without knowing more, they might be perfect with a different design.

My 2 cents ...

Eric


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.