22.2 Managing Transactions in Task Flows
A transaction is
a persisted collection of work that can be committed or rolled back
together as a group. You can use a bounded task flow to represent a
transaction and to declaratively manage transaction boundaries. In
the Fusion Order Demo application, the customer registration and
employee registration task flows are both implemented with the use of
task flow return activities. The Cancel button
implements rollback in the task flows. The Register button
on the
reviewCustomerInfo.jsff
and reviewEmployeeInfo.jsff
page
fragment files implement commit functionality.
An
end user can navigate from the shopping cart to initiate a backorder
request for an out-of-stock item. The backorder request application
is implemented as a bounded task flow that initiates a new
transaction upon entry.
Transaction
options on the called bounded task flow specify whether a called
bounded task flow should join an existing transaction, create a new
one, or create a new one only if there is no existing transaction.
If
the called bounded task flow is able to start a new transaction
(based on the
transaction
option
that you selected), you can specify whether the transaction will be
committed or rolled back when the task flow returns to its caller.
The commit and rollback options are set on the task flow return
activity that returns control back to the calling task flow. The same
task flow that starts a transaction must also resolve the
transaction.
In
a called bounded task flow, you can specify two different return task
flow activities that result in either committing or rolling back a
transaction in the called bounded task flow. Each of the task flow
return activities passes control back to the same calling task flow.
The difference is that one task flow return activity specifies the
commit option, while the other specifies the rollback option. As
shown in Figure
22-2,
if transaction processing successfully completes, control flow passes
to the success task flow return activity, which specifies options to
commit the transaction. If the transaction is cancelled before
completion, the cancel task flow activity specifies options to roll
back the transaction.
If
no transaction option is specified, a transaction is not started on
entry of the called bounded task flow. A runtime exception is thrown
if the bounded task flow attempts to access transactional services.
Use
the
restore-save-point
option
on the task flow return activity if you want to discard the changes
an end user makes within a called bounded task flow when the called
bounded task flow exits. ADF Controller rolls back to the previous
ADF Model save point that was created when the bounded task flow was
entered. The restore-save-point
option
applies only to cases when a bounded task flow is entered by joining
an existing transaction (either
the requires-existing-transaction
or requires-transaction
option
is also specified) and a save point is created upon entry.
Tip:
You
can use a return activity to call the
commit
action
or you can use a button bound to the commit
action.
If possible, use a task flow return activity. Using a task flow
return activity will commit all data controls used by the ADF task
flow. It also makes it easier to see where your application is doing
commits and rollbacks, and is therefore easier to maintain.
You
must use
invokeAction
if:- You want to commit before the end of a task flow.
- You are not using ADF Controller.
- The task flow uses multiple data controls and you do not want to commit all of them.
22.2.1 How to Enable Transactions in a Bounded Task Flow
Define
transaction options on a bounded task flow that is called by another
task flow. Add a task flow return activity on the called bounded task
flow that returns control to the task flow that calls the bounded
task flow.
It
may be helpful to have an understanding of what a transaction is and
how you can configure it. For more information, see Section
22.2, "Managing Transactions in Task Flows."
You
may also find it helpful to read about additional functionality that
you can add using other task flow features. For more information,
see Section
22.1.2, "Additional Functionality for Complex Task Flows."
- In the Application Navigator, double-click the source file for the called bounded task flow.
- In the overview editor, click the Behavior navigation tab and expand the Transaction section.
-
- <No Controller Transaction>: The called bounded task flow does not participate in any transaction management.
It
is recommended that you do not select this option for a bounded task
flow that is parent to multiple child bounded task flows that also
have the <No
Controller Transaction> setting.
Instead, selectUse
Existing Transaction if Possible for
the parent task flow to avoid the creation of multiple database
connections by each child bounded task flow.
- Always Use Existing Transaction: When called, the bounded task flow participates in an existing transaction already in progress.
- Use Existing Transaction If Possible: When called, the bounded task flow either participates in an existing transaction if one exists, or starts a new transaction upon entry of the bounded task flow if one doesn't exist.
- Always Begin New Transaction: A new transaction starts when the bounded task flow is entered, regardless of whether or not a transaction is in progress. The new transaction completes when the bounded task flow exits.
Note:
After
choosing a transaction option, you may also need to select the Share
data controls with calling task flow option
for the bounded task flow to determine whether there are any
interactions between the options. For more information, see Section
20.4.3, "What You May Need to Know About Managing Transactions."
- Optionally, deselect the Share data controls with calling task flow checkbox so that data controls are not shared with the calling task flow if you chose one of the following options in step 3:
- Use Existing Transaction If Possible
- Always Begin New Transaction
The
default behavior is to share data controls. For more information,
see Section
22.2.3, "What You May Need to Know About Data Control Scoping
with Task Flows."
- Optionally, select the No save point on task flow entry checkbox to prevent the creation of an ADF Model save point on task flow entry if you chose one of the following options in step 3:
- Always Use Existing Transaction
- Use Existing Transaction If Possible
An
ADF Model save point is a saved snapshot of the ADF Model state.
Selecting the No
save point on task flow entry checkbox
means that overhead associated with a save point is not created for
the transaction.
- Select the task flow return activity in the called bounded task flow.
- In the Property Inspector, expand the Behavior section.
- If the called bounded task flow supports creation of a new transaction (bounded task flow specifies Use Existing Transaction If Possible or Always Begin New Transaction options), select one of the following in the End Transaction dropdown list:
- commit: Select to commit the existing transaction to the database.
- rollback: Select to roll back a new transaction to its initial state on task flow entry. This has the same effect as cancelling the transaction.
- In the Restore Save Point dropdown list, select true if you want changes the user makes within the called bounded task flow to be discarded when the task flow exits. The save point that was created upon task flow entry will be restored.
22.2.2 What Happens When You Specify Transaction Options
Example
22-1 shows
the metadata for transaction options on a called bounded task flow.
The
<new-transaction>
element
indicates that a new transaction always starts when the called
bounded task flow is invoked.<task-flow-definition id="trans-taskflow-definition"> <default-activity>taskFlowReturn1</default-activity> <transaction> <new-transaction/> </transaction> <task-flow-return id="taskFlowReturn1"> <outcome> <name>success</name> <commit/> </outcome> </task-flow-return> </task-flow-definition>
Example
22-1 also
shows the metadata for transaction options on the task flow return
activity on the called task flow. The
<commit/>
element
commits the existing transaction to the database.
The<outcome>
element
specifies a literal outcome, for example, success
,
that is returned to the caller when the bounded task flow exits. The
calling ADF task flow can define control flow rules based on this
outcome to For more information about defining control flow upon
return, see Section
19.7, "Using Task Flow Return Activities."22.2.3 What You May Need to Know About Data Control Scoping with Task Flows
The
ADF Model layer exposes the
DataControlFrame
interface
to manage a transaction in which the data controls within the frame
participate. The DataControlFrame
interface
exposes methods such as:beginTransaction()
commit()
rollback()
Similarly,
ADF Controller allows a task flow to demarcate a transaction
boundary, to begin a transaction at task flow entry, and to either
commit or roll back the transaction on task flow exit. It does this
by invoking methods exposed by the ADF Model
layer's
DataControlFrame
interface.
ADF
Controller supports the transaction options listed in Table
22-1.
The behavior of these transaction options depends on whether you
select or deselect the Share
data controls with calling task flowcheckbox
(XML element:
<data-control-scope>
)
in the overview editor for a task flow.
<No
Controller Transaction>
|
The
DataControlFrame is
shared without an open transaction. |
|
---|---|---|
Always
Begin New Transaction
XML
element:
<new-transaction/> |
Begins
a new transaction if one is not already open and throws an
exception if one is already open.
|
|
Always
Use Existing Transaction
XML
element:
<requires-existing-transaction/> |
Throws
an exception if the transaction is not already open.
|
|
Use
Existing Transaction if Possible
XML
element:
<requires-transaction/> |
Begins
a new transaction if one is not already open.
|
Always
begins a new transaction.
|
트랜잭션 관리 작업 흐름에
트랜잭션이 커밋 또는 그룹으로 함께 롤백 할 수있는 작업의 지속성 된 컬렉션입니다. 당신은 트랜잭션을 표현하는 선언적인 트랜잭션 경계를 관리하기 위해 바인드 작업 흐름을 사용하실 수 있습니다. Fusion Order Demo 응용 프로그램은 고객 등록 및 직원의 등록 작업 흐름은 두 작업 플로우 리턴 활동의 사용에 의해 구현되어 있습니다. 취소 버튼은 작업 흐름 롤백을 구현하고 있습니다. 등록의 버튼 reviewCustomerInfo.jsff과 reviewEmployeeInfo.jsff 페이지 단편 파일은 기능성을 커밋 구현한다.
최종 사용자는 재고 항목에 대한 백 오더 요청을 시작하기 위해, 장바구니에서 탐색 할 수 있습니다. 백 오더 요청 애플리케이션은 입력 할 때 새로운 트랜잭션을 시작 바인드 작업 흐름으로 구현되어 있습니다.
라는 바인드 타스크 플로우의 트랜잭션 옵션 불리는 바인드 작업 흐름은 기존의 트랜잭션이없는 경우에만 기존의 트랜잭션에 참여하고 새로운 것을 만들거나 새로 만들 것인지 를 지정합니다.
라는 바인드 작업 흐름은 (에 따라 새로운 트랜잭션을 시작할 수 있다면 트랜잭션이 선택한 옵션)을 당신이 호출자에게 태스크 플로우 반환 트랜잭션을 커밋 또는 롤백할지 여부를 지정할 수 있습니다. 커밋과 롤백 옵션은 호출자의 작업 흐름에 제어를 돌려주는 태스크 플로우 반환 활동에 설정되어있다. 트랜잭션을 시작하고 같은 작업 흐름은 트랜잭션을 해결해야합니다.
라는 바인드 타스크 플로우는라는 바인드 태스크 플로우의 트랜잭션을 커밋 또는 롤백 중 하나가 될 두 가지 리턴 태스크 플로우 활동을 지정할 수 있습니다. 작업 플로우 수익 활동은 각각 뒷면 같은 호출자의 작업 흐름에 제어를 전달합니다. 차이는 다른 롤백 옵션을 지정하면서 하나의 태스크 플로우 반환 활동은 커밋 옵션을 지정하는 것이다. 와 같이 그림 22-2 트랜잭션 처리가 정상적으로 완료했을 경우, 제어 흐름은 트랜잭션을 커밋 옵션을 지정하고 성공 태스크 플로우 반환 활동에 전달합니다. 트랜잭션이 완료되기 전에 취소하면 작업 플로우 활동이 트랜잭션을 롤백하는 옵션을 지정합니다 취소.
호출 바인드 작업 흐름에서 22-2 태스크 플로우 반환 활동의 그림
여러 태스크 플로우 반환 활동.
트랜잭션 옵션을 지정하지 않는 경우는 트랜잭션이라는 바인드 작업 흐름 항목에서 시작되지 않습니다. 바인드 작업 플로우가 트랜잭션 서비스에 액세스하려고하면 런타임 예외가 throw됩니다.
사용 복원 세이브 포인트는 일반 사용자가 불리는 바인드 작업 흐름에서 할 변경 내용을 취소하려면 태스크 플로우 반환 활동에서 옵션을 때 호출 바인드 작업 흐름이 종료 합니다. ADF 컨트롤러는 바인드 작업 플로우가 입력 될 때 생성 된 시점의 세이브 이전 ADF 모델로 롤백합니다. 복원 세이브 포인트 바인드 작업 흐름은 기존의 트랜잭션에 참여하여 입력 된 때 옵션 (중 한가지의 경우에 적용되며, 기존의 트랜잭션을 필요로하거나 필요로하는 트랜잭션 옵션도 지정되어있다)와 세이브 포인트는 엔트리 때 생성되고있다.
팁 :
당신이 전화를 리턴 활동을 사용할 수 있습니다 커밋 작업을하거나 바인딩 된 버튼을 사용할 수 커밋 작업을. 가능하면 태스크 플로우 반환 활동을 사용하고 있습니다. 작업 플로우 수익 활동을 사용하면 ADF 작업 흐름에서 사용되는 모든 데이터 컨트롤을 커밋합니다. 또한 당신의 응용 프로그램이 커밋 또는 롤백을하고있는 장소가 쉽게 확인할 수 있으며, 따라서 유지 보수가 용이합니다.
당신이 사용해야합니다의 invokeAction를 한 경우 :
당신은 작업 흐름의 종료 전에 처리한다.
당신은 ADF 컨트롤러를 사용하지 않는다.
작업 흐름은 여러 데이터 컨트롤을 사용하여 당신은 그들 모두를 위탁 할 필요가 없습니다.
22.2.1 바인드 작업 흐름에서 거래를 활성화하는 방법
다른 작업 흐름에서 호출하는 바인드 작업 흐름에서 트랜잭션 옵션을 정의합니다. 바인드 작업 흐름을 호출하는 작업 흐름에 제어를 반환라는 바인드 작업 흐름 태스크 플로우 반환 활동을 추가합니다.
시작하기 전에 :
이것은 트랜잭션이 무엇인지를 이해하는 것이 도움이 될 당신은 그것을 설정하는 방법을 설명합니다. 자세한 내용은 섹션 22.2를 "작업의 트랜잭션을 관리하는 흐릅니다."
또한 당신은 다른 작업 흐름 기능을 사용하여 추가 할 수 있고 추가 기능에 대해 읽을 수 유용 할지도 모른다. 자세한 내용은 섹션 22.1.2 "복잡한 작업 흐름을위한 추가 기능을."
트랜잭션으로 실행하도록 바인드 작업 흐름을 활성화하려면 :
애플리케이션 네비게이터에서 불리는 바인드 작업 흐름의 소스 파일을 더블 클릭합니다.
개요 편집기에서 동작 탐색 탭을 전개하면 트랜잭션 섹션을.
드롭 다운 목록에서 다음 중 하나를 선택합니다.
<아니오 컨트롤러 거래> : 불리는 바인드 작업 흐름은 어떤 트랜잭션 관리에 참여하지 않습니다.
당신이 여러 아이의 부모도 가지고 작업 흐름 묶여이다 바인드 작업 흐름을 위해이 옵션을 선택하지 않는 것이 좋습니다 <아니오 컨트롤러의 트랜잭션> 설정. 그 대신 선택할 수있는 경우에 사용하는 기존의 트랜잭션을 각각의 아이에 의해 여러 데이터베이스 연결 만들기를 피하기 위해 부모 작업 흐름 작업 흐름을 경계.
항상 기존의 트랜잭션을 사용하십시오 : 호출되면 바인드 작업 흐름은 이미 진행중인 기존의 트랜잭션에 참여하고 있습니다.
가능하면 기존의 트랜잭션을 사용하십시오 : 호출되면 바인드 작업은 어느 흐름이 존재하는 경우, 기존의 트랜잭션에 참여하거나 하나가 존재하지 않는 경우는 바인드 작업 흐름 입력시 새 트랜잭션을 시작합니다.
항상 새로운 트랜잭션을 시작합니다 : 바인드 작업 흐름에 관계없이 트랜잭션이 진행 중인지 여부에 입력 된 때 새로운 트랜잭션이 시작됩니다. 때 바인드 작업 흐름을 종료 새로운 트랜잭션이 완료됩니다.
주의 :
트랜잭션 옵션을 선택한 후, 당신도 선택해야 태스크 플로우 호출과 공유 데이터 컨트롤을 옵션 사이에 상호 작용이 있는지를 판단하기 위해 바인드 작업 흐름 에 대한 옵션을 선택합니다. 자세한 내용은 섹션 20.4.3 "당신은 트랜잭션 관리에 필요한 지식을."
필요에 따라 선택을 취소 한 업무 흐름의 호출로 공유 데이터 컨트롤을 당신이 단계에서 다음 옵션 중 하나를 선택하면 해당 데이터 컨트롤은 호출 타스크 플로우 공유 되지 않도록 확인란을 3 :
가능하면 기존의 트랜잭션을 사용하십시오
항상 새로운 트랜잭션을 시작합니다
기본 동작은 데이터 컨트롤을 공유하는 것입니다. 자세한 내용은 섹션 22.2.3은 "무엇을 작업 및 제어 범위는 데이터 흐름에 대해 알 필요가 있을지도 모릅니다."
필요에 따라 선택한 작업 흐름 항목에서 포인트 저장 아니오 단계에서 다음 옵션 중 하나를 선택하면 작업 흐름 항목에서 포인트를 저장하는 ADF 모델의 작성을 방지하기 위해 확인란을 3 :
항상 기존의 트랜잭션
가능하면 기존의 트랜잭션을 사용하십시오
세이브 포인트 ADF 모델은 ADF 모델 상태의 저장된 스냅 샷입니다. 선택하는 작업 흐름 항목에 포인트를 저장하지 않지만 확인란과 세이브 포인트는 트랜잭션 용으로 작성되지 않은 관련 오버 헤드를 의미합니다.
라는 바인드 작업 흐름 태스크 플로우 반환 활동을 선택합니다.
속성 검사기에서 배포 할 동작 섹션을.
라는 바인드 작업 흐름은 새로운 트랜잭션 생성을 지원하는 경우 (바인드 작업 흐름이 가능한 경우에 사용하고 기존의 트랜잭션을하거나 항상 새로운 트랜잭션의 시작 옵션) 을에서 다음 중 하나를 선택 엔드 트랜잭션 드롭 다운 목록 :
커밋 : 데이터베이스에 대한 기존의 트랜잭션 커밋을 선택합니다.
롤백 작업 흐름 항목에 초기 상태로 새로운 트랜잭션을 롤백하려면 선택합니다. 이것은 트랜잭션을 취소하는 것과 같은 효과를 갖는다.
로 복원 세이브 포인트 드롭 다운 목록 선택한 진정한 사용자가 작업 흐름의 종료를 폐기라는 바인드 작업 흐름에서 변경하려는 경우. 작업 흐름 항목 중에 작성한 세이브 포인트가 복원됩니다.
22.2.2 트랜잭션 옵션을 지정할 때 발생하는
예 22-1는라는 바인드 타스크 플로우의 트랜잭션 옵션의 메타 데이터를 보여줍니다. <새 트랜잭션> 요소는라는 바인드 태스크 플로우가 호출 될 때 새로운 트랜잭션이 항상 실행중인 것을 나타냅니다.
예 22-1은 바인드 작업 흐름의 메타 데이터라는
<작업 흐름 정의 ID = "트랜스 작업 흐름 정의">
<기본 활동> taskFlowReturn1 </ 기본 - 활성>
<거래>
<새로운 트랜잭션 />
</ 거래>
<작업 플로우 리턴 ID = "taskFlowReturn1">
<성과>
<이름> 성공 </ name>
</ 커밋>
</ 성과>
</ 작업 흐름 리턴>
</ 작업 흐름 정의>
예 22-1은라고도 작업 흐름에서 작업 흐름 리턴 활동의 트랜잭션 옵션의 메타 데이터를 보여줍니다. <커밋 /> 요소는 데이터베이스에 대한 기존 트랜잭션을 커밋합니다. <성과> 요소는 리터럴 결과 예를 들어, 지정 성공 바인드 작업 흐름을 종료 호출자에게 반환. 호출 ADF 작업 흐름은 참조 복귀시에 제어 흐름의 정의에 대한 자세한 내용은이 결과에 따라 제어 흐름 규칙을 정의 할 수 19.7 항을 "태스크 플로우 반환 활동 사용"
22.2.3 작업 흐름을 사용하면 데이터 제어 범위 지정에 관한 필요한 지식
ADF 모델 계층은 공개 DataControlFrame 프레임의 데이터 컨트롤이 참여하는 트랜잭션을 관리하기위한 인터페이스를. DataControlFrame의 인터페이스는 다음과 같은 방법을 공개하고 있습니다.
의 beginTransaction ()
커밋 ()
롤백 ()
마찬가지로 ADF 컨트롤러는 작업 흐름 항목에서 거래를 시작하고 작업 플로우 종료시 트랜잭션을 커밋 또는 롤백하거나 트랜잭션 경계를 획정하는 작업 흐름을 가능하게한다. 이것은 ADF 모델 계층의 수에서 공개 된 메소드를 호출하여 작업을 수행 DataControlFrame 인터페이스를.
ADF 컨트롤러에 기재되어있는 트랜잭션의 옵션을 지원하고 표 22-1. 이러한 트랜잭션 옵션의 동작은, 선택 또는 선택 해제 여부에 따라 업무 흐름의 호출로 공유 데이터 컨트롤을 확인란 (XML 요소 : <데이터 제어 범위>) 작업 흐름 개요 편집기 로.
표 22-1 처리 설정 동작
트랜잭션 설정 공유 데이터 컨트롤 범위 데이터 컨트롤의 범위를 분리
<아니오 컨트롤러 거래>
DataControlFrame 오픈 트랜잭션없이 공유되고있다.
새로운 DataControlFrame 열려있는 트랜잭션없이 작성됩니다.
항상 새로운 트랜잭션을 시작합니다
XML 요소 : <새 트랜잭션 />
1 열려 있지 않으면 1이 이미 열려 있으면 예외를 throw하는 경우 새로운 트랜잭션을 시작합니다.
항상 새로운 트랜잭션을 시작합니다.
항상 기존의 트랜잭션
XML 요소 : <필요합니다 - 기존의 트랜잭션 />
트랜잭션이 아직 열려 있지 않으면 예외를 throw합니다.
잘못된. 확인란이 선택 해제 할 수 없습니다.
가능하면 기존의 트랜잭션을 사용하십시오
XML 요소 : <필요합니다 - 트랜잭션 />
1이 아직 열려 있지 않으면 새로운 트랜잭션을 시작합니다.
항상 새로운 트랜잭션을 시작합니다.
---------------------------------------------------------------
from - https://docs.oracle.com ~~~~ someWhere
N
https://translate.google.com/
Thks oracleNgoogle
댓글 없음:
댓글 쓰기