top of page

Unlocking the Power of Pega Queue Processor and Database Transactions

Problem statement

Assume you are developing a Queue Processor for an ATM Withdrawal use case. The process of ATM withdrawal consists of two operations.


Debit the amount from the Account table.

Insert a new record in the transaction history table.


The queue process we are planning to develop will take two parameters: Amount and Account number, and perform the above operations. Now assume if any of these two operations fail for any reason, what should our design be to manage the exception? Assume right after debiting the amount, the operation that deals with the transaction history table fails. In such a case, the customer will not see this transaction in the Account Statement, which will cause data inconsistency in the system. Have you ever thought about how to deal with this design issue? This issue would arise in all cases where more than one DB operation is performed under a single process.


The solution to this problem is possible by managing both operations as a single transaction. Or in simple words, we call it Transaction Management. In transaction management, either all operations will succeed or none will.


Pega Queue Processor is designed to execute each queue entry as a single transaction. Hence, if you add one queue entry when a customer withdraws an amount to perform an ATM withdrawal, either both operations will succeed, or if any fail, then all operations will be rolled back from the DB.


Let's take a look how Pega queue process achieve this


Execution Context

  • Queue processors run asynchronous background tasks triggered by Queue-For-Processing methods.

  • Each queued item is processed in its own transaction scope, independent of the user’s original request.


Transaction Boundaries

  • Commit behavior:

    • The system commits the original request first (e.g., case creation).

    • Then, the queue processor picks up the item in a new transaction.

  • Rollback behavior:

    • If the queue processor fails, only its transaction is rolled back.

    • The original user-facing transaction remains intact.


Error Handling & Retries

  • Pega automatically retries failed queue items based on retry count and delay settings.

  • Failed items are moved to the Broken Queue if retries are exhausted.

  • Best practice: implement error handling logic (e.g., try-catch in activities, error handling flows) to gracefully manage failures.


Best Practices for Consultants

  • Use dedicated queue processors for different business functions (e.g., notifications, integrations).

  • Monitor via Admin Studio → Queue Management for visibility into success/failure rates.

  • For external integrations, wrap calls in connectors with retry logic to handle transient failures.

  • Document transaction boundaries clearly for clients — this helps explain why background tasks may succeed/fail independently of user actions.


In short: Queue processors decouple background work from user transactions, with independent commit/rollback handling. This makes them powerful for scalability but requires careful design to avoid data inconsistencies.

Comments


©2022 by pegablogs. Proudly created with Wix.com

bottom of page