Best practices for writing background processing work

To maintain and manage your work resources and to ensure that resource performance is not compromised if a node becomes unexpectedly unavailable, design your work assignments to be thread-safe and use a multi-threaded environment.

To ensure your work resources remain thread-safe, follow these best practices:

  • Instead of agents, use Job Schedulers and Queue Processors for all new development. Agent rules are no longer being actively developed; Queue Processor rules replace standard agents. For best performance and maintainability, replace agents with Queue Processor rules. For more information, see Use Job Scheduler and Queue Processor rules instead of agents.
  • For advanced agents, ensure that any custom actions are thread-safe or specify that the agent runs only on one node at a time. For more information, see Avoiding race conditions for advanced agents. For more information about client-required post-upgrade steps in Pega Cloud Services environments, see Post-upgrade tasks following Pega Platform upgrades (7.x to 8.x) in Pega Cloud Services environments on Pega Community.
  • For Pega Cloud Services environments: Associate resources with node types rather than with specific node names or node IDs; associating a resource with a node ID can cause the resource to stop unexpectedly when the node is replaced, for example, due to a health check failure.
  • For on-premises environments:
    • To apply one or more node types to a node, use the JVM argument -DNodeTypes. For more information, see Assigning node types to nodes for on-premises environments.
    • To ensure system availability in the event that a node goes down unexpectedly, assign the same node type to multiple node instances.
    • Associate resources with node types rather than with specific node names or node IDs; this avoids resource failure if a node fails or you stop a node for maintenance.