커밋되지 않은 보류 중인 트랜잭션이 있는 경우 콜아웃이 허용되지 않습니다. 예를 들어 DML 작업 전에 저장 지점을 설정한 경우 해당 작업의 결과에 따라 저장 지점을 커밋하거나 롤백하는 콜아웃을 만들 수 없습니다.
때로는 레코드를 처리하는 동안 비즈니스 규칙에 따라, 이미 실행된 부분적인 작업(DML 문)을 롤백하여 다른 방향으로 처리를 계속해야 할 수 있습니다. Apex는 저장 지점, 즉 요청 내에서 특정 시점의 데이터베이스 상태를 지정하는 지점을 생성하는 기능을 제공합니다. 저장 지점 이후에 발생하는 모든 DML 문은 폐기될 수 있으며, 데이터베이스는 저장 지점를 생성했을 때의 상태로 복원됩니다.
예제 시나리오:
저장 지점 작업을 수행하려고 할 경우 계정을 삽입하여 중복을 찾고 롤백한 후 웹 서비스 콜아웃을 통해 계정 데이터를 외부 시스템으로 보냅니다. 하지만 웹 서비스가 호출되기 전에 다음 오류가 표시됩니다. '커밋되지 않은 보류 중인 작업이 있습니다. 호출 전 커밋 또는 롤백하십시오.'
요청 컨텍스트에서 보류 중인 트랜잭션으로 콜아웃을 만들 수 없습니다. 또한 명시적으로 커밋을 수행할 수 없습니다. 따라서 해결 방법은 별도의 컨텍스트에서 콜아웃을 만드는 것입니다.
콜아웃 전에는 DML 작업을 수행할 수 없습니다. 모든 DML 작업은 콜아웃을 완료한 후에만 호출해야 합니다. 그러므로 웹 서비스 콜아웃을 먼저 만든 후에 요청을 저장하십시오.
여러 개의 콜아웃을 만들 경우 모든 요청을 목록 또는 맵에 저장하고 저장한 콜아웃을 게시합니다.
다음 순서의 단계를 따르면 작동하게 됩니다.
쿼리
콜아웃
쿼리
콜아웃
삽입
콜아웃
콜아웃
콜아웃
삽입 또는 업데이트
다음의 시나리오 단계는 작동하지 않습니다.
콜아웃
삽입
콜아웃 <---- 여기에서 작동하지 않습니다.
VisualForce Page
<apex:actionFunction name="executeWS" action="{!executeWS}"></apex:actionFunction>
<apex:commandButton value="Save" action="{!save}" oncomplete="executeWS()" />
Controller
public PageReference save() {
insert obj;
}
public PageReference executeWS(){
obj = [SELECT ...];
try{
callout ws;
} catch(System.Exception ex){
delete obj;
ApexPages.addMessages(e);
return null;
}
return new PageReference('/' + id);
}
참고: Future 또는 Queueable 의 큐에 추가는 커밋되지 않은 작업이므로 콜아웃 전에는 해당 작업을 수행할 수 없습니다.
자세한 정보는 관련 링크 오류 - '트리거의 콜아웃은 현재 지원되지 않습니다.'를 참조하십시오.
000385708

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.