0

I have a webscript for which i don't want multiple calls at same time. If i get multiple calls at same time, i want to execute the webscript one after the other. Can we do that? If yes please explain the process.

Thanks in advance!

  • 1
    Welcome to StackOverflow. Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). – Marcos Pérez Gude Jul 13 '16 at 12:55
  • Add a synchronized block in the usual Java way? – Gagravarr Jul 13 '16 at 14:07

2 Answers2

2

Use the requiresnew in your webscript definition at first. This will make sure that every call is in it's own transaction and you won't get issues with rollingback etc.

In most cases this will solve all the issues you'll have. If not then you're probably fixing the problem at the wrong side and you'll need a queue before Alfresco like ActiveMQ.

Tahir Malik
  • 6,623
  • 15
  • 22
  • This solution will not guarantee the execution one after the other. And I think that Alfresco create a new transaction for every Webscript call even if the requiresnew is not set – izodev Jul 13 '16 at 18:19
  • No it doesn't and it's part of 1 big transaction. The only way to insure that is setting it to requiresnew. And if you use ActiveMQ and thus using a queue mechanism you can insure that they are executed after each other. – Tahir Malik Jul 13 '16 at 18:36
1

You can call a method with the synchronize annotation in the webscript's executeImp

izodev
  • 135
  • 8