Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
QueueableDuplicateSignature.Builder Class
Namespace
Examples
This example builds the async job signature with UserId and the string MyQueueable.
1AsyncOptions options = new AsyncOptions();
2options.DuplicateSignature = new System.QueueableDuplicateSignature.Builder()
3 .addId(UserInfo.getUserId())
4 .addString('MyQueueable')
5 .build();
6try {
7 System.enqueueJob(new MyQueueable(), options);
8} catch (DuplicateMessageException ex) {
9 //Exception is thrown if there is already an enqueued job with the same signature
10 Assert.areEqual('Attempt to enqueue job with duplicate queueable signature',
11 ex.getMessage());
12}This example builds the async job signature using ApexClass Id and the hash value of an sObject.
1AsyncOptions options = new AsyncOptions();
2options.DuplicateSignature = new QueueableDuplicateSignature.Builder()
3 .addInteger(System.hashCode(someAccount))
4 .addId([SELECT Id FROM ApexClass
5 WHERE Name='MyQueueable'].Id)
6 .build();
7System.enqueueJob(new MyQueueable(), options);QueueableDuplicateSignature.Builder Methods
The following are methods for QueueableDuplicateSignature.Builder.
addId(inputId)
Signature
public System.QueueableDuplicateSignature.Builder addId(Id id)
Parameters
- inputId: Type: Id
Return Value
addInteger(inputInteger)
Signature
public System.QueueableDuplicateSignature.Builder addInteger(Integer i)
Parameters
- inputInteger: Type: Integer
Return Value
addString(inputString)
Signature
public System.QueueableDuplicateSignature.Builder addString(String s)
Parameters
- inputString: Type: String
Return Value
build()
Signature
public System.QueueableDuplicateSignature build()
Return Value
getMaxSize()
Signature
public Integer getMaxSize()
Return Value
Type: Integer
getRemainingSize()
Signature
public Integer getRemainingSize()
Return Value
Type: Integer
getSize()
Signature
public Integer getSize()
Return Value
Type: Integer