本文整理汇总了Java中org.springframework.integration.core.MessageSource类的典型用法代码示例。如果您正苦于以下问题:Java MessageSource类的具体用法?Java MessageSource怎么用?Java MessageSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MessageSource类属于org.springframework.integration.core包,在下文中一共展示了MessageSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fileMessageSource
import org.springframework.integration.core.MessageSource; //导入依赖的package包/类
@Bean
@InboundChannelAdapter(value = "inboundFileChannel", poller = @Poller(cron = "${ticket.poller.cron}"))
public MessageSource<File> fileMessageSource(@Value("${ticket.poller.path}") final String path,
@Value("${ticket.poller.fileMask}") final String fileMask) {
final FileReadingMessageSource source = new FileReadingMessageSource();
final CompositeFileListFilter<File> compositeFileListFilter = new CompositeFileListFilter<>();
final SimplePatternFileListFilter simplePatternFileListFilter = new SimplePatternFileListFilter(fileMask);
final AcceptOnceFileListFilter<File> acceptOnceFileListFilter = new AcceptOnceFileListFilter<>();
compositeFileListFilter.addFilter(simplePatternFileListFilter);
compositeFileListFilter.addFilter(acceptOnceFileListFilter);
source.setFilter(compositeFileListFilter);
source.setDirectory(new File(path));
return source;
}
示例2: stockPriceChangeEvent
import org.springframework.integration.core.MessageSource; //导入依赖的package包/类
@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();
};
}
开发者ID:PacktPublishing,项目名称:Mastering-Spring-5.0,代码行数:16,代码来源:SignificantStockChangeSourceApplication.java
示例3: jdbcMessageSource
import org.springframework.integration.core.MessageSource; //导入依赖的package包/类
@Bean
public MessageSource<Object> jdbcMessageSource() {
JdbcPollingChannelAdapter jdbcPollingChannelAdapter =
new JdbcPollingChannelAdapter(this.dataSource, this.properties.getQuery());
jdbcPollingChannelAdapter.setMaxRowsPerPoll(this.properties.getMaxRowsPerPoll());
jdbcPollingChannelAdapter.setUpdateSql(this.properties.getUpdate());
return jdbcPollingChannelAdapter;
}
示例4: messageSource1
import org.springframework.integration.core.MessageSource; //导入依赖的package包/类
@Bean
@InboundChannelAdapter(value = MultiOutputSource.OUTPUT1, poller = @Poller(fixedDelay = "1000", maxMessagesPerPoll = "1"))
public synchronized MessageSource<String> messageSource1() {
return new MessageSource<String>() {
public Message<String> receive() {
String message = "FromSource1";
System.out.println("******************");
System.out.println("From Source1");
System.out.println("******************");
System.out.println("Sending value: " + message);
return new GenericMessage(message);
}
};
}
示例5: timerMessageSource
import org.springframework.integration.core.MessageSource; //导入依赖的package包/类
@Bean
@InboundChannelAdapter(value = MultiOutputSource.OUTPUT2, poller = @Poller(fixedDelay = "1000", maxMessagesPerPoll = "1"))
public synchronized MessageSource<String> timerMessageSource() {
return new MessageSource<String>() {
public Message<String> receive() {
String message = "FromSource2";
System.out.println("******************");
System.out.println("From Source2");
System.out.println("******************");
System.out.println("Sending value: " + message);
return new GenericMessage(message);
}
};
}
示例6: mongoSource
import org.springframework.integration.core.MessageSource; //导入依赖的package包/类
@Bean
protected MessageSource<Object> mongoSource() {
MongoDbMessageSource ms = new MongoDbMessageSource(mongoTemplate, new LiteralExpression(config.getQuery()));
ms.setCollectionNameExpression(new LiteralExpression(config.getCollection()));
ms.setEntityClass(String.class);
return ms;
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:8,代码来源:MongodbSourceConfiguration.java
示例7: integerMessageSource
import org.springframework.integration.core.MessageSource; //导入依赖的package包/类
@Bean
public MessageSource<?> integerMessageSource() {
MethodInvokingMessageSource source = new MethodInvokingMessageSource();
source.setObject(new AtomicInteger());
source.setMethodName("getAndIncrement");
return source;
}
示例8: setSource
import org.springframework.integration.core.MessageSource; //导入依赖的package包/类
public void setSource(MessageSource<?> source) {
ProxyFactory pf = new ProxyFactory(source);
class ReceiveAdvice implements MethodInterceptor {
private final List<ChannelInterceptor> interceptors = new ArrayList<>();
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
Object result = invocation.proceed();
if (result instanceof Message) {
Message<?> received = (Message<?>) result;
for (ChannelInterceptor interceptor : this.interceptors) {
received = interceptor.preSend(received, null);
if (received == null) {
return null;
}
}
return received;
}
return result;
}
}
final ReceiveAdvice advice = new ReceiveAdvice();
advice.interceptors.addAll(this.interceptors);
NameMatchMethodPointcutAdvisor sourceAdvisor = new NameMatchMethodPointcutAdvisor(advice);
sourceAdvisor.addMethodName("receive");
pf.addAdvisor(sourceAdvisor);
this.source = (MessageSource<?>) pf.getProxy();
}
示例9: timerMessageSource
import org.springframework.integration.core.MessageSource; //导入依赖的package包/类
@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");
}
};
}
示例10: timerMessageSource
import org.springframework.integration.core.MessageSource; //导入依赖的package包/类
@Bean
@InboundChannelAdapter(Source.OUTPUT)
public MessageSource<String> timerMessageSource() {
return new MessageSource<String>() {
@Override
public Message<String> receive() {
return MessageBuilder.withPayload(new SimpleDateFormat("DDMMMYYYY").format(new Date())).setHeader(MessageHeaders.CONTENT_TYPE,"text/plain").build();
}
};
}
示例11: xmlSource
import org.springframework.integration.core.MessageSource; //导入依赖的package包/类
@Bean
@InboundChannelAdapter(value = "pdfCreatorInputChannel", poller = @Poller("xmlFilePoller"))
public MessageSource<File> xmlSource() {
FileReadingMessageSource source = new FileReadingMessageSource();
source.setDirectory(config.getXmlDir());
source.setAutoCreateDirectory(true);
source.setFilter(new CompositeFileListFilter<>(
Arrays.asList(
new AgeFileListFilter(config.getXmlFileAge()),
new AcceptOnceFileListFilter<File>(config.getXmlSeenFilesQueueSize()),
new RegexPatternFileListFilter(config.getXmlFilePattern())
)));
return source;
}
示例12: timerMessageSource
import org.springframework.integration.core.MessageSource; //导入依赖的package包/类
@Bean
@InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedDelay = "${fixedDelay}", maxMessagesPerPoll = "1"))
public MessageSource<String> timerMessageSource() {
return () -> new GenericMessage<>(new SimpleDateFormat(this.format).format(new Date()));
}
示例13: fooBarStrings
import org.springframework.integration.core.MessageSource; //导入依赖的package包/类
@Bean
@InboundChannelAdapter(channel = Source.OUTPUT, poller = @Poller(fixedDelay = "100"))
public MessageSource<String> fooBarStrings() {
return () ->
new GenericMessage<>(this.semaphore.getAndSet(!this.semaphore.get()) ? "foo" : "bar");
}
示例14: timeSensorSource
import org.springframework.integration.core.MessageSource; //导入依赖的package包/类
@Bean
@InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedDelay = "${fixedDelay}", maxMessagesPerPoll = "1"))
public MessageSource<Sensor> timeSensorSource(){
return () -> new GenericMessage<Sensor>(randomSensor());
}
示例15: timerMessageSource
import org.springframework.integration.core.MessageSource; //导入依赖的package包/类
@Bean
@InboundChannelAdapter(value = Source.OUTPUT, autoStartup = "false", poller = @Poller(fixedDelay = "${fixedDelay}", maxMessagesPerPoll = "1"))
public MessageSource<String> timerMessageSource() {
return () -> new GenericMessage<>(new SimpleDateFormat(this.options.getFormat()).format(new Date()));
}