* Copyright (c) 2010. Axon Framework
* Licensed 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
* 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.
, but may also be obtained through the static
All instance methods in this class are meant to be used in a single thread and are therefore not thread-safe. The static methods are thread-safe.
private static final ThreadLocal<TransactionStatus> THREAD_LOCAL_TRANSACTION = new ThreadLocal<TransactionStatus>();
// construction limited to this package
Defaults to the number of events in the queue at the moment the transaction started.
maxTransactionSizeThe number of events to process in the current transaction
Typically, exceptions are caused by programming errors or the underlying processing environment that the event
handler uses, such as a database. In the former, there is no point in retrying the event processing. It would
cause an unlimited loop in event processing, making an application vulnerable to a poisonous message attack. In
the latter case, the event listener should identify which exception is transitive (i.e. might make a chance when
retried), and which is not. If an exception is transitive, either
RETRY_LAST_EVENT should be chosen.
Furthermore, the policy choice should be based on the effect of a transaction rollback. Some data sources, such
as databases, roll back the entire transaction. In that case, choose
RETRY_TRANSACTION policy. If a rollback on the underlying data source only rolls back the last modification,
If failed events should be ignored altogether, choose the
These policies may be set in both the
The latter would allow you to change policy based on the exact type of exception encountered.
retryPolicythe retry policy to apply when a transaction fails.
Note that negative values will result in immediate retries, making them practically equal to a value of 0.
to find out if transaction was successful or not.