/** * Custom poller poller metadata. * * @return the poller metadata */ @Bean(name = StreamSpanReporter.POLLER) PollerMetadata customPoller() { PollerMetadata poller = new PollerMetadata(); poller.setMaxMessagesPerPoll(500); poller.setTrigger(new PeriodicTrigger(5000L)); return poller; }
/** * @param maxMessagesPerPoll the maxMessagesPerPoll to set. * @return the spec. * @see PollerMetadata#setMaxMessagesPerPoll */ public PollerSpec maxMessagesPerPoll(long maxMessagesPerPoll) { this.target.setMaxMessagesPerPoll(maxMessagesPerPoll); return this; }
PollerSpec(Trigger trigger) { this.target = new PollerMetadata(); this.target.setAdviceChain(this.adviceChain); this.target.setTrigger(trigger); }
@Bean(name = PollerMetadata.DEFAULT_POLLER) public PollerMetadata defaultPoller() { PollerMetadata pollerMetadata = new PollerMetadata(); pollerMetadata.setTrigger(t -> null); return pollerMetadata; }
@Bean(name = PollerMetadata.DEFAULT_POLLER) public PollerMetadata defaultPoller() { PollerMetadata poller = new PollerMetadata(); poller.setTrigger(new PeriodicTrigger(60000)); MessagePublishingErrorHandler errorHandler = new MessagePublishingErrorHandler(); errorHandler.setDefaultErrorChannel(myErrors()); poller.setErrorHandler(errorHandler); return poller; }
public SourcePollingChannelAdapterSpec poller(PollerMetadata pollerMetadata) { if (pollerMetadata != null) { if (PollerMetadata.MAX_MESSAGES_UNBOUNDED == pollerMetadata.getMaxMessagesPerPoll()) { pollerMetadata.setMaxMessagesPerPoll(1); } this.endpointFactoryBean.setPollerMetadata(pollerMetadata); } return _this(); }
/** * Specify the {@link TransactionSynchronizationFactory} to attach a * {@link org.springframework.transaction.support.TransactionSynchronization} * to the transaction around {@code poll} operation. * @param transactionSynchronizationFactory the TransactionSynchronizationFactory to use. * @return the spec. */ public PollerSpec transactionSynchronizationFactory( TransactionSynchronizationFactory transactionSynchronizationFactory) { this.target.setTransactionSynchronizationFactory(transactionSynchronizationFactory); return this; }
/** * Specify the {@link ErrorHandler} to wrap a {@code taskExecutor} * to the {@link org.springframework.integration.util.ErrorHandlingTaskExecutor}. * @param errorHandler the {@link ErrorHandler} to use. * @return the spec. * @see #taskExecutor(Executor) */ public PollerSpec errorHandler(ErrorHandler errorHandler) { this.target.setErrorHandler(errorHandler); return this; }
@Test public void pollerWithTriggerReference() { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "pollerWithTriggerReference.xml", PollerParserTests.class); Object poller = context.getBean("poller"); assertNotNull(poller); PollerMetadata metadata = (PollerMetadata) poller; assertTrue(metadata.getTrigger() instanceof TestTrigger); context.close(); }
/** * Specify a timeout in milliseconds to wait for a message in the * {@link org.springframework.messaging.MessageChannel}. * Defaults to {@code 1000}. * @param receiveTimeout the timeout to use. * @return the spec. * @see org.springframework.messaging.PollableChannel#receive(long) */ public PollerSpec receiveTimeout(long receiveTimeout) { this.target.setReceiveTimeout(receiveTimeout); return this; }
/** * Specify an {@link Executor} to perform the {@code pollingTask}. * @param taskExecutor the {@link Executor} to use. * @return the spec. */ public PollerSpec taskExecutor(Executor taskExecutor) { this.target.setTaskExecutor(taskExecutor); return this; }
public PollerSpec sendTimeout(long sendTimeout) { this.target.setSendTimeout(sendTimeout); return this; }
public PollSkipAdvice() { this(new DefaultPollSkipStrategy()); }
@Bean public SimplePollSkipStrategy skipper() { return new SimplePollSkipStrategy(); }
@Bean(name = PollerMetadata.DEFAULT_POLLER) public PollerMetadata defaultPoller() { PollerMetadata pollerMetadata = new PollerMetadata(); pollerMetadata.setTrigger(new PeriodicTrigger(500)); pollerMetadata.setMaxMessagesPerPoll(2000); return pollerMetadata; }
@Bean public PollerMetadata myPoller() { PollerMetadata pollerMetadata = new PollerMetadata(); pollerMetadata.setTrigger(new PeriodicTrigger(11)); return pollerMetadata; }
@Test public void checkConfigWithAttribute() { Object poller = context.getBean("pollerWithAttribute"); assertEquals(PollerMetadata.class, poller.getClass()); PollerMetadata metadata = (PollerMetadata) poller; Trigger trigger = metadata.getTrigger(); assertEquals(CronTrigger.class, trigger.getClass()); DirectFieldAccessor accessor = new DirectFieldAccessor(trigger); String expression = (String) new DirectFieldAccessor( accessor.getPropertyValue("sequenceGenerator")) .getPropertyValue("expression"); assertEquals("*/10 * 9-17 * * MON-FRI", expression); }
@Bean(name = PollerMetadata.DEFAULT_POLLER) public PollerMetadata defaultPoller() { PollerMetadata pollerMetadata = new PollerMetadata(); pollerMetadata.setTrigger(new PeriodicTrigger(500)); pollerMetadata.setMaxMessagesPerPoll(2000); return pollerMetadata; }
@Bean(name = PollerMetadata.DEFAULT_POLLER) public PollerMetadata defaultPoller() { PollerMetadata pollerMetadata = new PollerMetadata(); pollerMetadata.setTrigger(new PeriodicTrigger(10)); return pollerMetadata; }