• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interceptors and Multithreading

 
sridhar nagarhalli
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic