Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Apex Design Patterns

You're reading from  Apex Design Patterns

Product type Book
Published in Apr 2016
Publisher
ISBN-13 9781782173656
Pages 256 pages
Edition 1st Edition
Languages
Authors (2):
Anshul Verma Anshul Verma
Profile icon Anshul Verma
Jitendra Zaa Jitendra Zaa
Profile icon Jitendra Zaa
View More author details

The active object pattern


To overcome the preceding race condition in concurrency, we can use the active object pattern.

Note

The active object pattern decouples the method execution from its invocation. Mostly, the active object pattern executes in asynchronous mode. Requesters submit a task as an object in a queue, and a scheduler picks an object from the queue and executes its logic. An object in the queue knows what to do when invoked, and that's the reason why the name of the pattern is active object.

As Apex does not support multithreading, we cannot create a shareable queue, which can be accessed by multiple threads simultaneously; and therefore, we will do it with the help of the  Pending_Request__c custom object. This custom object will save all the necessary information of the pending tasks that need to be performed asynchronously by the active object pattern.

Note

Do not confuse a shareable queue with the Salesforce queue. Here, a queue means a list of objects available in memory...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime}