Search code examples
asynchronousliferayliferay-6

Best way to implement async call on User login event in liferay


In liferay 6.2 we need to communicate to a Web service at the time of the user login and the call is expected to be asynchronous, i.e. the user login continues without being impacted from the web service call (even in case of remote exception).

I am not sure where I can plug the call to this web service. I tried with: 1. User Model Listener = > It halts until the remote call is finished (I added the call at @onBeforeUpdate and @onAfterUpdate ) 2. User login post action => It halts until the remote call is finished.

I read about the messaging implementation for async calls, is this the only way forward, or can there be a simpler approach that I am overlooking?

Thanks!


Solution

  • There is no out-of-the-box async method in Liferay that you can use - only synchronous methods. However, if the web service that you call is implemented asynchronously, it wouldn't halt the execution of your Liferay hook. You'll have to check with your webservice's implementation why it blocks execution when it shouldn't (as you say "it's expected to be asynchronous").