Search in sources :

Example 1 with CallableWithAccountLock

use of org.killbill.billing.payment.core.ProcessorBase.CallableWithAccountLock in project killbill by killbill.

the class OperationCallbackBase method dispatchWithAccountLockAndTimeout.

//
// Dispatch the Callable to the executor by first wrapping it into a CallableWithAccountLock
// The dispatcher may throw a TimeoutException, ExecutionException, or InterruptedException; those will be handled in specific
// callback to eventually throw a OperationException, that will be used to drive the state machine in the right direction.
//
protected <ExceptionType extends Exception> OperationResult dispatchWithAccountLockAndTimeout(final String pluginNames, final DispatcherCallback<PluginDispatcherReturnType<OperationResult>, ExceptionType> callback) throws OperationException {
    final Account account = paymentStateContext.getAccount();
    logger.debug("Dispatching plugin call for account {}", account.getExternalKey());
    try {
        final Callable<PluginDispatcherReturnType<OperationResult>> task = new CallableWithAccountLock<OperationResult, ExceptionType>(locker, account.getId(), paymentConfig, callback);
        final OperationResult operationResult = PaymentPluginDispatcher.dispatchWithExceptionHandling(account, pluginNames, task, paymentPluginDispatcher);
        return operationResult;
    } catch (final PaymentApiException e) {
        throw unwrapExceptionFromDispatchedTask(e);
    }
}
Also used : Account(org.killbill.billing.account.api.Account) PluginDispatcherReturnType(org.killbill.billing.payment.dispatcher.PluginDispatcher.PluginDispatcherReturnType) CallableWithAccountLock(org.killbill.billing.payment.core.ProcessorBase.CallableWithAccountLock) OperationResult(org.killbill.automaton.OperationResult) PaymentApiException(org.killbill.billing.payment.api.PaymentApiException)

Aggregations

OperationResult (org.killbill.automaton.OperationResult)1 Account (org.killbill.billing.account.api.Account)1 PaymentApiException (org.killbill.billing.payment.api.PaymentApiException)1 CallableWithAccountLock (org.killbill.billing.payment.core.ProcessorBase.CallableWithAccountLock)1 PluginDispatcherReturnType (org.killbill.billing.payment.dispatcher.PluginDispatcher.PluginDispatcherReturnType)1