blob: 3c7d821e5a27d4204f919b5a5b1507eefee8b656 [file] [log] [blame]
---
title: Suspending and Resuming Transactions
---
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
The ability to suspend and resume transactions is useful when a thread must perform operations that should not be part of the transaction before the transaction can complete.
When a transaction is suspended, it loses the transactional view of the cache. None of the previous operations (before calling suspend) are visible to the thread. Subsequently any operations that are performed by the thread do not participate in the suspended transaction.
When a transaction is resumed, the resuming thread assumes the transactional view. A transaction that is suspending on a member must be resumed on the same member. Before resuming a transaction, you may want to check if the transaction exists on the member and whether it is suspended. You may optionally use the `tryResume` method.
If the member with the primary copy of the data crashes, the transactional view that applied to that data is lost. The secondary member for the data cannot resume transactions suspended on the crashed member. You need to take remedial steps to retry the transaction on a new primary copy of the data.
If a suspended transaction is not touched for a period of time, <%=vars.product_name%> cleans it up automatically. By default, the timeout for a suspended transaction is 30 minutes and can be configured by using the `suspended-tx-timeout` property of the `geode.properties` file. The suspended transaction timeout value is specified in milliseconds.
See [Running a Client Transaction](running-client-xact.html) for code examples that show a how to suspend and resume a transaction.