Question
Xchanging
IN
Last activity: 17 Mar 2017 9:42 EDT
Assign Work Objects to Agents running on multiple nodes in cluster and All workobject grouped on particular criteria should be processed by one agent.
We have requirement where a group of workobjects need to be processed by an agent running on node in cluster environment. Can we achieve this through Engine API while queuing the Work object can we specify something related to Node so that the agent running on that node should pick the work object.
***Updated by moderator: Lochan to update Categories***
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
IN
May I know what are you trying to achieve either executed by an agent in the same node or other? Just trying to understand the use case.
I don't understand the need of clustered environment in such cases.
Looks like we need to dig towards product side whether we can group the "x" number of work object treated as a single request.
Xchanging
IN
Hi Dilip,
Requirement 1:
Suppose some work object(Let's say 10) queued to standard agent . That standard agent is running on four nodes. On the basis of certain criteria we need to add these work object under some parent case (the parent case might be existing or not) . So if suppose two work object need to be added under same parent case and that parent case in not existing and if these work object got picked by two agent in parallel then it might create two different parent case which will break the functionality.
Requirement 2:
As per our requirement suppose we have 10 work objects having same parent case queued to custom standard agent .That standard agent is running on four nodes. The 10 work objects which are being queued to these agents need to be processed .During processing they need to acquire lock on parent case and update some details on the parent case.Now if these work objects processed in parallel they might get locking issues .
Pegasystems Inc.
IN
Hello Pankaj,
Follow below PDN article where it’s clearly mentioned how to run agent only on one node in cluster .
https://community.pega.com/knowledgebase/release-note/run-advanced-agents-only-one-node-cluster
Based on this you can schedule the agent where in activity you can group the work objects and process as per your requirement .
Thanks,
Arun
Xchanging
IN
Hi Aurn,
Thanks for the reply but that is not our requirement.
Rgds,
Pankaj
Areteans Technology Solutions
AU
HI Pankaj,
The whole idea here to cook up a code that is node specific so that we can make sure that the agents don't process the items that are supposed to be processed by another node's agent.
The below algorithm works in the assumption that both the child and the parent WOs have a valid IDs. The decision to process a certain WO cannot be made until unless the item is picked by the agent.
For requirement 2 since that is easier to implement:
Assume that we have 4 nodes, with IDs, 1,2,3,4.
Multiple child WOs are being assigned to the standard agents for processing. Once the agent instance wakes up and picks an instance for processing, child case (C-1234)
1) Do a read only open of the parent case.
2) Get the ID of the parent case.
3) Assume it something like P-5678 (some random number)
4) Now, you can get the count of nodes that are active with the agents enabled either from a DSS rule provided you are sure that the agents are enabled and ready for processing OR you can query the Data-Agent-Queue to get the list of agent schedule instances that are enabled and ready for processing. - Count = 4
Caution: This can never increase or decrease during processing.
5) Now do a modulo of the ID with the count i.e 4538 modulo 10 = 8 (Result)
6) Result < Count ? Result+1 is the node that needs to process the Child instance.
HI Pankaj,
The whole idea here to cook up a code that is node specific so that we can make sure that the agents don't process the items that are supposed to be processed by another node's agent.
The below algorithm works in the assumption that both the child and the parent WOs have a valid IDs. The decision to process a certain WO cannot be made until unless the item is picked by the agent.
For requirement 2 since that is easier to implement:
Assume that we have 4 nodes, with IDs, 1,2,3,4.
Multiple child WOs are being assigned to the standard agents for processing. Once the agent instance wakes up and picks an instance for processing, child case (C-1234)
1) Do a read only open of the parent case.
2) Get the ID of the parent case.
3) Assume it something like P-5678 (some random number)
4) Now, you can get the count of nodes that are active with the agents enabled either from a DSS rule provided you are sure that the agents are enabled and ready for processing OR you can query the Data-Agent-Queue to get the list of agent schedule instances that are enabled and ready for processing. - Count = 4
Caution: This can never increase or decrease during processing.
5) Now do a modulo of the ID with the count i.e 4538 modulo 10 = 8 (Result)
6) Result < Count ? Result+1 is the node that needs to process the Child instance.
7) Result >= Count ? Result modulo Count = Result. Repeat 6 and 7 until you get a Node ID.
Eg: 8 < 4 ? NO --> 8 modulo 4 --> 0 = Result. From 6, Result+1 = 1 --> Node 1 needs to process this child instance.
So, even though an agent from another node has picked up the child, since the result indicates that the current instance need to processed by another Node agent, the current agent can stop further processing and re-queue the current child instance.
Let me know if you need any more update on this. Once you understand this the requirement 1s solution would be fairly simple. Else let me know, i will provide a solution for Requirement 1.
Xchanging
IN
Hi Ratan,
Thanks for the reply.
Simliar approach i thought but that was depending on Node ID . We can store the node id on work object pyworkpage and when agent fetched the workobject from queue we can check the Node id on which agent running if both are same the agent can process the work object otherwise we can requeue the work object. But in that probability of work object being assigned to correct agent is 100/NumberOfNode . I don't want to go with that approach because in most of the cases work object will be requeued that will waste the resource.
Do you have any way (Public API) which we can used to specify Node ID while calling the Queue-for-Agent to queue the work object that the agent running on that particular node can dequeue the work object.
Areteans Technology Solutions
AU
Are you looking for an API which let's you control the agent instance to pick their corresponding WO? though the queuing is done generic to all?
Areteans Technology Solutions
AU
Also, having the Node ID in the workobject is not correct in terms of business since Node ID is not a property of the DataModel created. Also, if you stick to the Node ID in the work object, then there is a huge chance that a certain node might need to take heavy load whereas other nodes might be having lesser to none to process.
Xchanging
IN
Hi Ratan,
Yes I am looking for API to control work object to be processed by Agent.
We can handled the Load on each node by entering the details in temp table which already present in our design.
Rgds,
Pankaj
Areteans Technology Solutions
AU
You can look into the System-Queue-DefaultEntry!EstablishContext activity where you can get choosy based on the node ID. Hope this helps
Xchanging
IN
Hi Ratan,
i already gone through the java Code in EstablishContext activity . But did not find anything which could help to assign the work object to be picked by agent running on particular node.
Areteans Technology Solutions
AU
That activity is open for extension. You can make the agent pick a queued item and then check a decision table and then decide to process the obtained item or to re-queue it so that other agent can pick it up for processing.
Or you can create 4 agents each running on different nodes and queue the items to them.
Ag1 running only in node1
Ag2 running only in node2
This way you will have the specific agent intances running in the specific nodes only though it can be run in all 4. In such an implementation, you get to decide before even queuing the instances. This is a simpler way to satisfy the requirement.
Hope this works out.
Xchanging
IN
-
Pegasystems Inc.
US
Hi Pankaj,
I see that you left a comment. Were you needing more assistance? Please let us know!
Thanks!
Xchanging
IN
Hi Marissa,
Yes , I am still looking for solution .
Regards,
Pankaj
Pegasystems Inc.
US
Pankaj,
I am not aware of an API to let you dictate which node/agent will pick up a specific queue item. The simplest solution is to create a different agent on each node and decide which one you want to have process the item at the queue for agent invocation. I think overall it sounds like your design is overly complex and trying to guard against an edge case that there system already provides alternatives to. If you are trying to work on the same parent simultaneously from two children, yes, one will get a locking error. But the queue item should be requeued and try again, so provided you are only holding the lock for a short period of time, the other item will get picked up and worked on a subsequent attempt.
Thanks,
Mike
Pegasystems
US
If an agent knows it wants to update or create a parent called P-123, and is worried that another agent on another node might clash and erroneously update or create the SAME parent, the agent can do a lock on string "P-123". That guarantees that no other agent will interfere.
If the agent fails to get the lock on "P-123", it can requeue the request to run a little later. Presumably, when it does run later, it will succeed in getting the lock on "P-123" at which point it can discover that another agent already created the P-123 object.
To get info about how to lock on a string instead of an object, click on "(i) > APIs > Engine APIs" and look at class "LockManager".
/Eric