• 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

Asynchronous Job withou JMS

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can spawn a new thread from the main thread, and let the new child thread take care of invoking EJB.
 
Dave Coopa
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic