Posted: 27 Oct 2016 1:55 EDT Last activity: 9 Nov 2016 11:51 EST
Accessing pyMaxAttempts and pyAttempts via the Agent activity
I want to be able to access pyMaxAttempts and pyAttempts via the Agent activity. However, as the work item is the primary page for the Agent activity, how do I get access to these properties to determine pyAttempts / pyMaxAttempts so that I can perform a different action if pyAttempts = pyMaxAttempts?
I confirmed the Work item is the Primary page by using tools.getPrimaryPage().getXML() and it printed out the XML representation of the work item I was expecting to be processed.
***Updated by moderator: Lochan to create new post from this comment; add categories***
This is a very intersting question . A good spot to try is trace the agent and see at runtime what is the context for the pyMaxAttempts properties ? From there you can drill down further to see how you can play with that programmatically .
To see how you can trace an agent, please refer this short video .
Thank you for the response. Thank you for the link. I tried the steps in there and I continue to see this error: "Please restart Tracer because Tracer session error: session Bxyz does not exist." I am not sure if this error is related to the frequency of the agent (60 seconds) or if it's because I am testing this within Oracle VirtualBox, or if it's because it is Pega 7.1.8. I am going to retry with a personal edition and a non VirtualBox install and let you know. I also looked at another Agent activity (pyCallProcessRequest that sits in RS: Pega-RuleRefactoring:07-10-01) that seems to use Obj-List, Obj-Sort against System-Queue-DefaultEntry to find the most recent record to then load the Work object -- which is slightly different than the way I am obtaining the record.
Where do you set pyMaxAttempts property are you using request processor rule?
Have you tried mapping a page to the System-Queue- class (with the proper queue type for example System-Queue-DefaultEntry or System-Queue-ExecutionRequest-Connect-Default) ?
If you define a page over the appropriate System-Queue- class type you will get both pyAttempts and pyMaxAttempts values. However pyMaxAttempts is something that user has to set manually so the question is where exactly you have set it?
I have configured the pyMaxAttempts in the Queue-For-Agent call that puts the Work object on the Agent Queue. Via SMA, the System-Queue-DefaultEntry is properly shown (with pyMaxAttempts and pyAttempts) being present with proper values. However, in the Agent Activity, all that is accessible via the Primary Page is the actual Work Object that I put on the Queue with no way to access to the System-Queue-DefaultEntry. I tried using the Pages & Classes for System-Queue-DefaultEntry with a Page Name of QueuePage (not sure what to use) but that results in the activity not fully executing to completion -- which makes sense because the QueuePage has no value; If this is the right way to go, what Page Name should be used.?
Here's how I got it to work (with direction from your responses and assistance from GCS).
To access all properties from System-Queue-DefaultEntry, this is what needs to be done.
1. For the Activity that puts items on the Agent Queue. When calling Queue-For-Agent, the step page used for this step (say, QueuePage) should be of class System-Queue-DefaultEntry. For any reference to a work object that needs to be done, this value (or the complete object) should be set on a property applied to the System-Queue-DefaultEntry object. A Page-New was created and the Work Object and/or data was addd to the property to the newly created object. Note: all of the other properties (i.e. pyAttempts or pyMaxAttempts) are not set or have values set here but rather by Pega within the process of obtaining the elemetn off of the queue.
2. The Agent Definition. When defining the agent, the class that the agent applies to should be of type: System-Queue-DefaultEntry (the same from item 1 above)
3. The agent activity referenced from the agent definition (in 2 above) should apply to System-Queue-DefaultEntry. By doing this, the primary page on the activity will give you access to all of the required properties (specifically pyAttempts and pyMaxAttempts) of System-Queue-DefaultEntry. To get access to the Work Object, the newly added property can be referenced to be dealt with appropriately.