LockService 或 JobLockService 锁定节点

发布于 2024-11-26 15:57:58 字数 580 浏览 1 评论 0原文

LockService 和 JobLockService 在户外有什么区别,如果我已经存在一个节点代表创建的其他节点的序列,并且该节点必须在 getNextSequence() 之前锁定,那么我可以在哪里使用它们?

例如:

Node sequenceNode = getSequenceNode();
LockService(sequenceNode);
Node aNode = new Node(new NodeRef(...));
Map<QName,serialzable> props = new HashMap<QName,Serializable>();
props.put(...,sequenceNode.getNextSequence()); 
nodeService.setProperty(..,..,..,props);

现在,LockService 是否足以满足这一点,因为知道序列节点不可通过露天 Web 客户端编辑,只能通过这行代码进行编辑。

非常感谢您的回复。 穆罕默德·阿米尔 高级系统开发人员 数字系列公司

What is the difference between LockService and JobLockService in the alfresco and where i can use both of them in case i have a node already exist represents the sequence of other nodes created, and that node must be locked before getNextSequence() ?

as example:

Node sequenceNode = getSequenceNode();
LockService(sequenceNode);
Node aNode = new Node(new NodeRef(...));
Map<QName,serialzable> props = new HashMap<QName,Serializable>();
props.put(...,sequenceNode.getNextSequence()); 
nodeService.setProperty(..,..,..,props);

Now, is LockService enough for this knowing the sequenceNode not editable by alfresco web client, only will be edit by this line of code.

you replies are highly appreciated.
Mohammed Amr
Senior System Developer
Digital Series Co.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌吟 2024-12-03 15:57:58

tl;dr:使用 LockService 并感到高兴,在这种情况下这对您来说就足够了。

LockService 用于获取特定节点上的锁,而 JobLockService 用于处理特定任务上的并发。更具体地说:

  • 只要您想要对特定节点或一组节点进行独占访问,就可以使用LockService。您必须指定要锁定哪些节点以及哪些 您要应用的锁定类型。一旦您获得了一个或多个节点上的锁定,系统将禁止其他用户访问这些节点,并且将继续这样做,直到您删除锁定或锁定过期

  • 您使用JobLockService时需要一次仅执行一次特定任务(例如,以避免并发运行)。此服务处理的锁不绑定到特定节点,并由 QName 标识。因此,JobLockService 不会阻止任何节点被访问或修改,而是禁止其他线程或外部应用程序执行相同的任务(前提是它们首先尝试获取相同的锁)。假设您有多个访问存储库的远程系统。 JobLockService 允许您在整个系统网络上强制串行执行相同的任务。

如果我正确理解您的问题,您有一个节点保存序列号或类似的东西,并且您需要 getNextSequence 可靠地提供下一个标识符。虽然您可以在这里使用这两种服务,但由于关键操作实际上绑定到单个节点(保存序列的节点),因此我宁愿在这里使用 LockService

tl;dr: Use the LockService and be happy, it's enough for you in this case.

LockService is intended to acquire locks on specific nodes, while JobLockService is used to handle concurrency on specific tasks. More specifically:

  • you use the LockService whenever you want exclusive access on a specific node or a set of nodes. You have to specify which nodes you want to lock and which type of lock you want to apply. Once you gained the lock on one or more nodes the system will inhibit other users from accessing such nodes, and will keep doing so until you remove the lock or it expires

  • you use the JobLockService when you need specific tasks to be executed only once at a time (e.g. to avoid concurrency runs). Locks handled by this service are not bound to specific nodes, and are identified by QNames. As a result, JobLockService doesn't prevent any node from being accessed or modified, but rather inhibit other threads or external applications from executing the same task (provided they first try to acquire the same lock). Say you have several remote systems that access the repository. The JobLockService allows you to force serial execution of the same taks on the whole network of systems.

If I understand your problem correctly, you have a node holding a sequence number or something similar, and you need the getNextSequence to be reliably providing the next identifier. While you could use both services here, since the critical operation is really bound to a single node (the one holding the sequence), I would rather use the LockService here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文