当前位置: 首页>>代码示例>>Java>>正文


Java MessageSource类代码示例

本文整理汇总了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;
}
 
开发者ID:create1st,项目名称:spring-batch,代码行数:15,代码来源:IntegrationConfiguration.java

示例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;
}
 
开发者ID:spring-cloud-stream-app-starters,项目名称:jdbc,代码行数:9,代码来源:JdbcSourceConfiguration.java

示例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);
		}
	};
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-samples,代码行数:15,代码来源:SampleSource.java

示例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);
		}
	};
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-samples,代码行数:15,代码来源:SampleSource.java

示例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;
}
 
开发者ID:EldadDor,项目名称:Spring-Integration-ShowCase,代码行数:8,代码来源:FilterConfiguration.java

示例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();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:31,代码来源:DefaultPollableMessageSource.java

示例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");
		}
	};
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:11,代码来源:CustomPartitionedProducerTest.java

示例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();
		}
	};
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:11,代码来源:TestSource.java

示例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;
}
 
开发者ID:djarosz,项目名称:fopator,代码行数:15,代码来源:Fopator.java

示例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()));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-samples,代码行数:6,代码来源:SourceModuleDefinition.java

示例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");
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-samples,代码行数:7,代码来源:FooBarSource.java

示例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());
}
 
开发者ID:viniciusccarvalho,项目名称:schema-evolution-samples,代码行数:6,代码来源:SensorSource.java

示例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()));
}
 
开发者ID:trisberg,项目名称:cloud-examples,代码行数:6,代码来源:TimeSource.java


注:本文中的org.springframework.integration.core.MessageSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。