private SourcePollingChannelAdapter buildChannelAdapter() { SourcePollingChannelAdapter adapter = new SourcePollingChannelAdapter(); adapter.setSource(mock(MessageSource.class)); adapter.setOutputChannel(new QueueChannel()); adapter.setTrigger(mock(Trigger.class)); adapter.setBeanFactory(mock(BeanFactory.class)); adapter.setTaskScheduler(mock(TaskScheduler.class)); adapter.afterPropertiesSet(); return adapter; }
spca.setOutputChannel(this.outputChannel);
private void configure(SourcePollingChannelAdapter adapter) { adapter.setOutputChannel(new NullChannel()); adapter.setBeanFactory(this.beanFactory); adapter.setTaskScheduler(this.threadPoolTaskScheduler); }
spca.setOutputChannel(this.outputChannel);
pollingChannelAdapter.setOutputChannel(new NullChannel()); pollingChannelAdapter.setBeanFactory(mock(BeanFactory.class)); pollingChannelAdapter.afterPropertiesSet();
adapter.setMaxMessagesPerPoll(3); adapter.setTrigger(new PeriodicTrigger(60000)); adapter.setOutputChannel(channel); adapter.setErrorHandler(t -> { throw new IllegalStateException("unexpected exception in test", t);
adapter.setTrigger(new PeriodicTrigger(100)); QueueChannel out = new QueueChannel(); adapter.setOutputChannel(out); adapter.setBeanFactory(mock(BeanFactory.class)); adapter.afterPropertiesSet();
adapter.setOutputChannel(outputChannel); adapter.setSource(new MessageSource<String>() {
adapter.setOutputChannel(outputChannel); adapter.setSource(new MessageSource<String>() {
@Test public void errorChannelWithFailedDispatch() throws InterruptedException { TestApplicationContext context = TestUtils.createTestApplicationContext(); QueueChannel errorChannel = new QueueChannel(); QueueChannel outputChannel = new QueueChannel(); context.registerChannel("errorChannel", errorChannel); CountDownLatch latch = new CountDownLatch(1); SourcePollingChannelAdapter channelAdapter = new SourcePollingChannelAdapter(); channelAdapter.setSource(new FailingSource(latch)); PollerMetadata pollerMetadata = new PollerMetadata(); pollerMetadata.setTrigger(new PeriodicTrigger(1000)); channelAdapter.setOutputChannel(outputChannel); context.registerEndpoint("testChannel", channelAdapter); context.refresh(); latch.await(2000, TimeUnit.MILLISECONDS); Message<?> message = errorChannel.receive(5000); context.close(); assertNull(outputChannel.receive(100)); assertNotNull("message should not be null", message); assertTrue(message instanceof ErrorMessage); Throwable exception = ((ErrorMessage) message).getPayload(); assertEquals("intentional test failure", exception.getCause().getMessage()); }
adapter.setOutputChannel(outputChannel); adapter.setSource(new MessageSource<String>() {
adapter.setOutputChannel(outputChannel); adapter.setSource(new MessageSource<String>() {
adapter.setOutputChannel(outputChannel); adapter.setSource(new MessageSource<String>() {
adapter.setOutputChannel(outputChannel);
private void initializeAdapter() { synchronized (this.initializationMonitor) { if (this.initialized) { return; } Assert.notNull(this.source, "source is required"); Assert.notNull(this.outputChannel, "outputChannel is required"); SourcePollingChannelAdapter spca = new SourcePollingChannelAdapter(); spca.setSource(this.source); spca.setOutputChannel(this.outputChannel); if (this.pollerMetadata == null) { this.pollerMetadata = IntegrationContextUtils.getDefaultPollerMetadata(this.beanFactory); Assert.notNull(this.pollerMetadata, "No poller has been defined for channel-adapter '" + this.beanName + "', and no default poller is available within the context."); } spca.setTrigger(this.pollerMetadata.getTrigger()); spca.setMaxMessagesPerPoll(this.pollerMetadata.getMaxMessagesPerPoll()); spca.setTaskExecutor(this.pollerMetadata.getTaskExecutor()); spca.setTransactionManager(this.pollerMetadata.getTransactionManager()); spca.setTransactionDefinition(this.pollerMetadata.getTransactionDefinition()); spca.setAdviceChain(this.pollerMetadata.getAdviceChain()); spca.setAutoStartup(this.autoStartup); spca.setBeanName(this.beanName); spca.setBeanFactory(this.beanFactory); spca.setBeanClassLoader(this.beanClassLoader); spca.afterPropertiesSet(); this.adapter = spca; this.initialized = true; } }