List of usage examples for org.springframework.integration.endpoint PollingConsumer setTransactionSynchronizationFactory
public void setTransactionSynchronizationFactory( TransactionSynchronizationFactory transactionSynchronizationFactory)
From source file:org.springframework.integration.config.ConsumerEndpointFactoryBean.java
private void initializeEndpoint() throws Exception { synchronized (this.initializationMonitor) { if (this.initialized) { return; }//from w ww. j a v a2 s. co m MessageChannel channel = null; if (StringUtils.hasText(this.inputChannelName)) { Assert.isTrue(this.beanFactory.containsBean(this.inputChannelName), "no such input channel '" + this.inputChannelName + "' for endpoint '" + this.beanName + "'"); channel = this.beanFactory.getBean(this.inputChannelName, MessageChannel.class); } if (this.inputChannel != null) { channel = this.inputChannel; } Assert.state(channel != null, "one of inputChannelName or inputChannel is required"); if (channel instanceof SubscribableChannel) { Assert.isNull(this.pollerMetadata, "A poller should not be specified for endpoint '" + this.beanName + "', since '" + channel + "' is a SubscribableChannel (not pollable)."); this.endpoint = new EventDrivenConsumer((SubscribableChannel) channel, this.handler); } else if (channel instanceof PollableChannel) { PollingConsumer pollingConsumer = new PollingConsumer((PollableChannel) channel, this.handler); if (this.pollerMetadata == null) { this.pollerMetadata = PollerMetadata.getDefaultPollerMetadata(this.beanFactory); Assert.notNull(this.pollerMetadata, "No poller has been defined for endpoint '" + this.beanName + "', and no default poller is available within the context."); } pollingConsumer.setTaskExecutor(this.pollerMetadata.getTaskExecutor()); pollingConsumer.setTrigger(this.pollerMetadata.getTrigger()); pollingConsumer.setAdviceChain(this.pollerMetadata.getAdviceChain()); pollingConsumer.setMaxMessagesPerPoll(this.pollerMetadata.getMaxMessagesPerPoll()); pollingConsumer.setErrorHandler(this.pollerMetadata.getErrorHandler()); pollingConsumer.setReceiveTimeout(this.pollerMetadata.getReceiveTimeout()); pollingConsumer.setTransactionSynchronizationFactory( this.pollerMetadata.getTransactionSynchronizationFactory()); pollingConsumer.setBeanClassLoader(beanClassLoader); pollingConsumer.setBeanFactory(beanFactory); this.endpoint = pollingConsumer; } else { throw new IllegalArgumentException("unsupported channel type: [" + channel.getClass() + "]"); } this.endpoint.setBeanName(this.beanName); this.endpoint.setBeanFactory(this.beanFactory); this.endpoint.setAutoStartup(this.autoStartup); this.endpoint.afterPropertiesSet(); this.initialized = true; } }