*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Asynchronous Job withou JMS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Asynchronous Job withou JMS" Watch "Asynchronous Job withou JMS" New topic
Author

Asynchronous Job withou JMS

Dave Coopa
Greenhorn

Joined: Aug 19, 2008
Posts: 2
Hello,

I have a question regarding asynchronous process:
Let suppose a stateless EJB needs to perform a long process (say 5 min) but that the client does not want/need to wait until the process is finished.

In order to enable such process, is it required to use JMS: send a message to a MDB that will do the job?
It sounds strange to set up a messaging system only for processing long run tasks.

Thanks in advance for your opinions,

Dave
wang andrew
Ranch Hand

Joined: May 12, 2008
Posts: 31
you can spawn a new thread from the main thread, and let the new child thread take care of invoking EJB.
Dave Coopa
Greenhorn

Joined: Aug 19, 2008
Posts: 2
Executing the work in a thread is what I would do for a client application. But in the server context it is prohibited to span thread because this process is not under control of the container (App Server). The application server should manage all the resources being indeed.

Any other idea ?
Gabriel Belingueres
Ranch Hand

Joined: Feb 09, 2007
Posts: 34
You could have a task that fires at regular time intervals to process all pending work. The work producer saves it into a shared repository (a database for example)
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
It sounds strange to set up a messaging system only for processing long run tasks.


Sending a message from the Session EJB to a queue sounds like a good idea. This can be implemented rather easily and is very straight-forward.

A simple Message-Driven EJB will pick up the message and do the 5+ minute processing.
mc khan
Greenhorn

Joined: Aug 14, 2008
Posts: 19
You can wrap your SLB as a JAS-WS webservice and let your client invoke it asynchronously or you can also wrap it as a one-way webservice. Internally the container would use helper threads to accomplish this.

According to the EJB3 spec you can also send a message to a local MBD without the need for MOM. I have not seen a real world example of this approach.

Good luck,
-Maqbool.
Chaminda Amarasinghe
Ranch Hand

Joined: May 17, 2006
Posts: 402
Hi,

According to my experience MDB is a very good option for this type of situations. Other interesting thing with JMS-MDB is (ejb3) its supports for legacy systems as well,

Also Khan's suggestion seems a very good approach,

Good Luck
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Asynchronous Job withou JMS
 
Similar Threads
which technology better for file transferring
More resources for tier architecture?
regarding Point-to-Point messaging system
Asynchronous communication among clients?
moving from j2se to jee