aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Interceptors and Multithreading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Interceptors and Multithreading" Watch "Interceptors and Multithreading" New topic
Author

Interceptors and Multithreading

sridhar nagarhalli
Greenhorn

Joined: May 01, 2013
Posts: 1
Hi, I am a new bee to EJB and wanted some suggestions on Multithreading with Interceptors.
My project requirement is, we need to log some message before an call to merge or persistEntity is called. So I decided to use interceptor and got it working, but I want to further do some business logic in the interceptor and do not want the actual ejb call to wait till the business logic is completed. So in short, I want to fork a new thread for my business logic and do a context.proceed() so that the actual call goes thru.
Please share your thoughts......

Thanks
Sridhar
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10289
    
168

sridhar nagarhalli wrote:
but I want to further do some business logic in the interceptor and do not want the actual ejb call to wait till the business logic is completed. So in short, I want to fork a new thread for my business logic and do a context.proceed() so that the actual call goes thru.

Interceptors aren't meant for spawning threads within a Java EE environment. What exactly is the use case?

[My Blog] [JavaRanch Journal]
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

You should not create threads within EJBs. Instead you can inject EJB in your interceptor and invoke a method from injected EJB that is annotated with @Asynchronous.


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Interceptors and Multithreading