Java Code Examples for org.springframework.integration.annotation.Poller

The following examples show how to use org.springframework.integration.annotation.Poller. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-cloud   Source File: DataProducer.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedDelay = "10000", maxMessagesPerPoll = "1"))
public MessageSource<TimeInfo> timerMessageSource() {
    return () -> MessageBuilder.withPayload(
            TimeInfo.builder().time(Long.toString(System.currentTimeMillis())).label(UUID.randomUUID().toString()).build())
            .build();
}
 
Example 2
Source Project: spring-cloud   Source File: SampleSource.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@InboundChannelAdapter(value = MultiOutputSource.OUTPUT1, poller = @Poller(fixedDelay = "1000", maxMessagesPerPoll = "1"))
public synchronized MessageSource<String> messageSource1() {
    return new MessageSource<String>() {
        public Message<String> receive() {
            return new GenericMessage<String>("message1_" + UUID.randomUUID().toString());
        }
    };
}
 
Example 3
Source Project: spring-cloud   Source File: SampleSource.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@InboundChannelAdapter(value = MultiOutputSource.OUTPUT2, poller = @Poller(fixedDelay = "1000", maxMessagesPerPoll = "1"))
public synchronized MessageSource<String> messageSource2() {
    return new MessageSource<String>() {
        public Message<String> receive() {
            return new GenericMessage<String>("message2_" + UUID.randomUUID().toString());
        }
    };
}
 
Example 4
Source Project: activiti-examples   Source File: DemoApplication.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@InboundChannelAdapter(value = "fileChannel", poller = @Poller(fixedDelay = "1000"))
public MessageSource<File> fileReadingMessageSource() {
    FileReadingMessageSource sourceReader = new FileReadingMessageSource();
    sourceReader.setDirectory(new File(INPUT_DIR));
    sourceReader.setFilter(new SimplePatternFileListFilter(FILE_PATTERN));
    return sourceReader;
}
 
Example 5
Source Project: java-examples   Source File: SftpConfig.java    License: MIT License 5 votes vote down vote up
@Bean
@InboundChannelAdapter(channel = "fromSftpChannel", poller = @Poller(cron = "0/5 * * * * *"))
public MessageSource<File> sftpMessageSource() {
    SftpInboundFileSynchronizingMessageSource source = new SftpInboundFileSynchronizingMessageSource(
            sftpInboundFileSynchronizer());
    source.setLocalDirectory(new File(sftpLocalDirectoryDownload));
    source.setAutoCreateLocalDirectory(true);
    source.setLocalFilter(new AcceptOnceFileListFilter<File>());
    return source;
}
 
Example 6
@Bean
@InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedDelay = "60000", maxMessagesPerPoll = "1"))
public MessageSource<StockPriceChangeEvent> stockPriceChangeEvent() {

	StockTicker[] tickers = StockTicker.values();
	String randomStockTicker = tickers[ThreadLocalRandom.current().nextInt(tickers.length)].name();

	return () -> {
		StockPriceChangeEvent event = new StockPriceChangeEvent(randomStockTicker,
				new BigDecimal(getRandomNumber(10, 20)), new BigDecimal(getRandomNumber(10, 20)));

		logger.info("sending " + event);
		return MessageBuilder.withPayload(event).build();
	};
}
 
Example 7
@Bean
@InboundChannelAdapter(value = "unsortedChannel", poller = @Poller(fixedDelay = "100"))
public MessageSource<InputStream> unsortedChannelAdapter(Storage gcs) {
	GcsStreamingMessageSource adapter =
			new GcsStreamingMessageSource(new RemoteFileTemplate<>(new GcsSessionFactory(gcs)));
	adapter.setRemoteDirectory("gcsbucket");
	adapter.setFilter(new AcceptOnceFileListFilter<>());

	return adapter;
}
 
Example 8
@Bean
@InboundChannelAdapter(value = "sortedChannel", poller = @Poller(fixedDelay = "100"))
public MessageSource<InputStream> sortedChannelAdapter(Storage gcs) {
	GcsStreamingMessageSource adapter =
			new GcsStreamingMessageSource(
					new RemoteFileTemplate<>(new GcsSessionFactory(gcs)),
					Comparator.comparing(blob -> blob.getName()));

	adapter.setRemoteDirectory("gcsbucket");
	adapter.setFilter(new AcceptOnceFileListFilter<>());

	return adapter;
}
 
Example 9
/**
 * An inbound channel adapter that polls the GCS bucket for new files and copies them to
 * the local filesystem. The resulting message source produces messages containing handles
 * to local files.
 * @param synchronizer an inbound file synchronizer
 * @return a message source
 */
@Bean
@InboundChannelAdapter(channel = "new-file-channel", poller = @Poller(fixedDelay = "5000"))
public MessageSource<File> synchronizerAdapter(GcsInboundFileSynchronizer synchronizer) {
	GcsInboundFileSynchronizingMessageSource syncAdapter = new GcsInboundFileSynchronizingMessageSource(
			synchronizer);
	syncAdapter.setLocalDirectory(Paths.get(this.localDirectory).toFile());

	return syncAdapter;
}
 
Example 10
/**
 * An inbound channel adapter that polls the remote directory and produces messages with
 * {@code InputStream} payload that can be used to read the data from remote files.
 * @param gcs a storage client to use
 * @return a message source
 */
@Bean
@InboundChannelAdapter(channel = "copy-channel", poller = @Poller(fixedDelay = "5000"))
public MessageSource<InputStream> streamingAdapter(Storage gcs) {
	GcsStreamingMessageSource adapter = new GcsStreamingMessageSource(
			new GcsRemoteFileTemplate(new GcsSessionFactory(gcs)));
	adapter.setRemoteDirectory(this.gcsReadBucket);
	return adapter;
}
 
Example 11
@Bean
@InboundChannelAdapter(channel = "pubsubInputChannel", poller = @Poller(fixedDelay = "100"))
public MessageSource<Object> pubsubAdapter(PubSubTemplate pubSubTemplate) {
	PubSubMessageSource messageSource = new PubSubMessageSource(pubSubTemplate,  "exampleSubscription");
	messageSource.setMaxFetchSize(5);
	messageSource.setAckMode(AckMode.MANUAL);
	messageSource.setPayloadType(String.class);
	return messageSource;
}
 
Example 12
@Bean
@InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedDelay = "5000", maxMessagesPerPoll = "1"))
public MessageSource<String> timerMessageSource() {
	return new MessageSource<String>() {
		@Override
		public Message<String> receive() {
			throw new MessagingException("test");
		}
	};
}
 
Example 13
@Bean
@InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedDelay = "5000", maxMessagesPerPoll = "1"))
public MessageSource<String> timerMessageSource() {
	return new MessageSource<String>() {
		@Override
		public Message<String> receive() {
			throw new MessagingException("test");
		}
	};
}
 
Example 14
Source Project: tutorials   Source File: TxIntegrationConfig.java    License: MIT License 5 votes vote down vote up
@Bean
@InboundChannelAdapter(value = "inputChannel", poller = @Poller(value = "pollerMetadata"))
public MessageSource<File> fileReadingMessageSource() {
    FileReadingMessageSource sourceReader = new FileReadingMessageSource();
    sourceReader.setDirectory(new File(INPUT_DIR));
    sourceReader.setFilter(new SimplePatternFileListFilter(FILE_PATTERN));
    return sourceReader;
}
 
Example 15
Source Project: tutorials   Source File: FileCopyConfig.java    License: MIT License 5 votes vote down vote up
@Bean
@InboundChannelAdapter(value = "fileChannel", poller = @Poller(fixedDelay = "10000"))
public MessageSource<File> fileReadingMessageSource() {
    FileReadingMessageSource sourceReader = new FileReadingMessageSource();
    sourceReader.setDirectory(new File(INPUT_DIR));
    sourceReader.setFilter(new SimplePatternFileListFilter(FILE_PATTERN));
    return sourceReader;
}
 
Example 16
@Bean
@InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedDelay = "10000", maxMessagesPerPoll = "1"))
public MessageSource<Long> timeMessageSource() {
	return () -> MessageBuilder.withPayload(new Date().getTime()).build();
}
 
Example 17
Source Project: Mastering-Spring-Cloud   Source File: OrderApplication.java    License: MIT License 4 votes vote down vote up
@Bean
@InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedDelay = "1000", maxMessagesPerPoll = "1"))
public MessageSource<Order> ordersSource() {
	Random r = new Random();
	return () -> new GenericMessage<>(new Order(OrderStatus.NEW, (long) r.nextInt(5), Collections.singletonList((long) r.nextInt(10))));
}
 
Example 18
Source Project: schema-evolution-samples   Source File: SensorSource.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
@InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedDelay = "${fixedDelay}", maxMessagesPerPoll = "1"))
public MessageSource<Sensor> timeSensorSource(){
	return () -> new GenericMessage<Sensor>(randomSensor());
}
 
Example 19
Source Project: schema-evolution-samples   Source File: SensorSource.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
@InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedDelay = "${fixedDelay}", maxMessagesPerPoll = "1"))
public MessageSource<Sensor> timeSensorSource(){
	return () -> new GenericMessage<Sensor>(randomSensor());
}
 
Example 20
Source Project: spring-bus   Source File: ModuleDefinition.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
@InboundChannelAdapter(value = "output", autoStartup = "false", poller = @Poller(fixedDelay = "${fixedDelay}", maxMessagesPerPoll = "1"))
public MessageSource<String> timerMessageSource() {
	return () -> new GenericMessage<>(new SimpleDateFormat(format).format(new Date()));
}
 
Example 21
Source Project: batchers   Source File: EmployeeJobConfigMaster.java    License: Apache License 2.0 4 votes vote down vote up
@Aggregator(sendPartialResultsOnExpiry = true, sendTimeout = RECEIVE_TIMEOUT, inputChannel = "inboundResults", outputChannel = "replyChannel",
        poller = @Poller(maxMessagesPerPoll = "5", fixedDelay = "10000"))
public List<?> aggregate(@Payloads List<?> messages) {
    return messages;
}
 
Example 22
Source Project: tutorials   Source File: TimeSourceApplication.java    License: MIT License 4 votes vote down vote up
@Bean
@InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedDelay = "10000", maxMessagesPerPoll = "1"))
public MessageSource<Long> timeMessageSource() {

    return () -> MessageBuilder.withPayload(new Date().getTime()).build();
}