SalesForce Platform Dev -- Asynchronous Apex

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What parameters does the Database.BatchableContext method take?

-- A reference to the Database.BatchableContext object -- A list of sObjects or a returned list from the Database.QueryLocator

When would you typically use asynchronous Apex?

-- Callouts to external systems. -- Operations that require higher limits. -- Code that needs to run at a certain time.

What arguments does the System.Schedulable method take?

-- Name for the job -- Cron expression -- Name of the class instance

Name 4 best practices for using batch apex.

1.) Only use if more than one batch. If not, use queueable apex. 2.) Tune SOQL to gather records as quickly as possible. 3.) Minimize number of async requests to minimize chance of delays. 4.) Use care when invoking from a trigger to ensure that trigger won't add more batch jobs than the limit.

How many scheduled apex jobs can you have at one time?

100

How many SOQL queries are allowed with asynchronous calls?

200

What is the default batch size for the data passed to the execute method?

200

How many jobs can you add to the queue with system.enqueujob in a single transaction?

50

What is the limit on future calls per Apex invocation?

50

What is the syntax to create a web service callout from a future method?

@future (callout=true)

In test methods, when is asynchronous apex executed?

After test.stopTest().

What happens when stopTest is executed with asynchronous methods?

All the asynchronous calls made after startTest are collected and then run synchronously.

How can you reorder asynchronous jobs through the Salesforce user interface?

Apex Flex Queue

What object can be used to track batch jobs?

AsyncApexJob

How to you execute a class that has been implemented with the Schedulable interface?

Call the System.Schedule method

What feature of Queueable Apex is useful if you need to do sequential processing?

Chaining

What object is created after a class is scheduled?

CronTrigger

What is a common use of Batch Apex?

Data cleansing or archiving of records.

What class must you implement for a Batch Apex class.

Database.Batchable

How do you test future methods?

Enclose test code between Test.startTest and Test.stopTest.

What are the three parts of the asynchronous request lifecycle in the SFDC multi-tenant environment?

Enqueue. Persistence. Put in persistent storage for failure recovery and transactional capabilities. Dequeue. Removed from queue and processed.

How do you maintain state with batch apex?

Implement database.stateful in the batch class

What maintains its state in batch apex that implements database.stateful?

Instance member variables.

How do you invoke a batch class?

Instantiate it and then call the Database.executeBatch(batch instance) method with the instance as a parameter.

What happens after you submit a queueable class for execution?

It is added to the queue and will be processed when system resources become available.

When type of jobs is batch Apex used for?

Large jobs -- thousands or millions of records that would exceed normal processing limits. Data cleansing or archiving.

Are batches of records guaranteed to execute in the order they are received from the start method?

No

Are synchronous web service callouts supported from scheduled apex?

No

Can a future method take standard or custom objects as arguments?

No

Can add more than one child job in the execute method?

No

Can future methods be used in VisualForce controllers in getMethodName() or setMethodName() or in the constructor?

No

Can getContent() and getContentAsPDF() be used in future methods?

No

Can test code make callouts to external systems?

No

Can you call a future method from a future method?

No

If one batch transaction fails, are other batch transactions rolled back?

No

Is there any limit on the depth of chained jobs?

No

Are future methods guaranteed to execute in the order they are called?

No.

Do future jobs show up in the apex flex queue?

No. Only in the Apex jobs page.

What does the Database.Batchable execute() method do?

Performs actual processing for each chunk passed to method.

What is one concern with scheduling a job from a trigger?

Possibly adding more job classes than the limit.

What types of parameters can future methods receive?

Primitive, array of primitives, or collection of primitives.

What is a good solution when asynchronous methods need to be executed in the order they are called?

Queueable Apex.

What could happen if two future methods run concurrently and try to update the same record?

Record locking.

What is the parameter of the schedulable interface execute method?

SchedulableContext

What methods does the Database.Batchable interface include?

Start Execute Finish

Are future methods instance or class (static) methods?

Static

How do you chain jobs in queueable apex?

Submit the second job from the execute method of the first.

How is queueable apex called?

System.enqueuejob()

What is a common scenario for using Queueable Apex?

Taking a set of sObject records, executing processing like making a callout to a REST endpoint, and then updating the asynchronously.

What is the second parameter than can be passed to the executeBatch() method?

The batch size to be passed to the execute() method.

Why can't objects be passed to future methods?

The object can change between the time it is passed to the future method and when the method is executed.

A future method must be used when making callouts from a trigger or after performing a DML operation. True or False?

True

True or False. Future methods run in their own thread.

True

True or False. Every batch transaction starts with a new set of governor limits.

True.

True or False. Queueable apex can use more than just primitive data types.

True.

How would you make asynchronous callouts with scheduled jobs?

Use @future and call that method from the scheduled Apex or call batch apex.

What does the finish() method do?

Used for post-processing actions, such as sending an email and is called once all batches are processed.

What does the Database.Batchable start method do?

Used to collect records or objects to be passed to the interface method execute for processing.

What is the return type of future methods?

Void

What is something to minimize the use of in batch apex?

Web Service callout times

What is one common use of @future methods?

Web service callout.

What is one scenario where you would want to use a future method instead of queueable apex?

When functionality is sometimes executed synchronously and sometimes asynchronously.

How can you get information on a scheduled job?

Write a query against CronTrigger.

What is the only method that the schedulable interface contains?

execute

What is the syntax for writing an Apex scheduler?

global class someClass implements Schedulable


Ensembles d'études connexes

SECURITY + INTRUSION DETECTION AND PREVENTION 6.8

View Set

Chapter 12: Miscellaneous Commercial Policies

View Set

Management and Organizational Behavior

View Set

Brain, Spinal Cord, and Nervous Review

View Set

Introduction to Federal Fair Housing Laws

View Set

Chapter 4: Calcium & Power Stroke

View Set

CSC 121: People in Computing Quiz

View Set

chromosomal abnormalities PRACTICE QUIZ

View Set