Search in sources :

Example 1 with PassThroughTransactionSynchronizationFactory

use of org.springframework.integration.transaction.PassThroughTransactionSynchronizationFactory in project spring-integration by spring-projects.

the class AbstractPollingEndpoint method onInit.

@Override
protected void onInit() {
    synchronized (this.initializationMonitor) {
        if (this.initialized) {
            return;
        }
        Assert.notNull(this.trigger, "Trigger is required");
        if (this.taskExecutor != null) {
            if (!(this.taskExecutor instanceof ErrorHandlingTaskExecutor)) {
                if (this.errorHandler == null) {
                    Assert.notNull(this.getBeanFactory(), "BeanFactory is required");
                    this.errorHandler = new MessagePublishingErrorHandler(new BeanFactoryChannelResolver(getBeanFactory()));
                    this.errorHandlerIsDefault = true;
                }
                this.taskExecutor = new ErrorHandlingTaskExecutor(this.taskExecutor, this.errorHandler);
            }
        }
        if (this.transactionSynchronizationFactory == null && this.adviceChain != null) {
            if (this.adviceChain.stream().anyMatch(TransactionInterceptor.class::isInstance)) {
                this.transactionSynchronizationFactory = new PassThroughTransactionSynchronizationFactory();
            }
        }
        this.initialized = true;
    }
    try {
        super.onInit();
    } catch (Exception e) {
        throw new BeanInitializationException("Cannot initialize: " + this, e);
    }
}
Also used : BeanInitializationException(org.springframework.beans.factory.BeanInitializationException) TransactionInterceptor(org.springframework.transaction.interceptor.TransactionInterceptor) MessagePublishingErrorHandler(org.springframework.integration.channel.MessagePublishingErrorHandler) BeanFactoryChannelResolver(org.springframework.integration.support.channel.BeanFactoryChannelResolver) PassThroughTransactionSynchronizationFactory(org.springframework.integration.transaction.PassThroughTransactionSynchronizationFactory) MessagingException(org.springframework.messaging.MessagingException) BeanInitializationException(org.springframework.beans.factory.BeanInitializationException) ErrorHandlingTaskExecutor(org.springframework.integration.util.ErrorHandlingTaskExecutor)

Aggregations

BeanInitializationException (org.springframework.beans.factory.BeanInitializationException)1 MessagePublishingErrorHandler (org.springframework.integration.channel.MessagePublishingErrorHandler)1 BeanFactoryChannelResolver (org.springframework.integration.support.channel.BeanFactoryChannelResolver)1 PassThroughTransactionSynchronizationFactory (org.springframework.integration.transaction.PassThroughTransactionSynchronizationFactory)1 ErrorHandlingTaskExecutor (org.springframework.integration.util.ErrorHandlingTaskExecutor)1 MessagingException (org.springframework.messaging.MessagingException)1 TransactionInterceptor (org.springframework.transaction.interceptor.TransactionInterceptor)1