org.springframework.cloud.stream.messaging.Source Java Examples
The following examples show how to use
org.springframework.cloud.stream.messaging.Source.
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 File: ContentTypeTests.java From spring-cloud-stream with Apache License 2.0 | 6 votes |
@Test public void testSendBinaryDataWithContentTypeUsingHeaders() throws Exception { try (ConfigurableApplicationContext context = SpringApplication.run( SourceApplication.class, "--server.port=0", "--spring.jmx.enabled=false")) { MessageCollector collector = context.getBean(MessageCollector.class); Source source = context.getBean(Source.class); byte[] data = new byte[] { 0, 1, 2, 3 }; source.output().send(MessageBuilder.withPayload(data) .setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.IMAGE_JPEG) .build()); Message<byte[]> message = (Message<byte[]>) collector .forChannel(source.output()).poll(1, TimeUnit.SECONDS); assertThat( message.getHeaders().get(MessageHeaders.CONTENT_TYPE, MimeType.class) .includes(MimeTypeUtils.IMAGE_JPEG)); assertThat(message.getPayload()).isEqualTo(data); } }
Example #2
Source File: ContentTypeTests.java From spring-cloud-stream with Apache License 2.0 | 6 votes |
@Test public void testSendStringType() throws Exception { try (ConfigurableApplicationContext context = SpringApplication.run( SourceApplication.class, "--server.port=0", "--spring.jmx.enabled=false", "--spring.cloud.stream.bindings.output.contentType=text/plain")) { MessageCollector collector = context.getBean(MessageCollector.class); Source source = context.getBean(Source.class); User user = new User("Alice"); source.output().send(MessageBuilder.withPayload(user).build()); Message<String> message = (Message<String>) collector .forChannel(source.output()).poll(1, TimeUnit.SECONDS); assertThat( message.getHeaders().get(MessageHeaders.CONTENT_TYPE, MimeType.class) .includes(MimeTypeUtils.TEXT_PLAIN)); assertThat(message.getPayload()).isEqualTo(user.toString()); } }
Example #3
Source File: ContentTypeTests.java From spring-cloud-stream with Apache License 2.0 | 6 votes |
@Test public void testSendBynaryData() throws Exception { try (ConfigurableApplicationContext context = SpringApplication.run( SourceApplication.class, "--server.port=0", "--spring.jmx.enabled=false")) { MessageCollector collector = context.getBean(MessageCollector.class); Source source = context.getBean(Source.class); byte[] data = new byte[] { 0, 1, 2, 3 }; source.output() .send(MessageBuilder.withPayload(data) .setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_OCTET_STREAM) .build()); Message<byte[]> message = (Message<byte[]>) collector .forChannel(source.output()).poll(1, TimeUnit.SECONDS); assertThat( message.getHeaders().get(MessageHeaders.CONTENT_TYPE, MimeType.class) .includes(MimeTypeUtils.APPLICATION_OCTET_STREAM)); assertThat(message.getPayload()).isEqualTo(data); } }
Example #4
Source File: DataProducer.java From spring-cloud with Apache License 2.0 | 6 votes |
@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 #5
Source File: ContentTypeTests.java From spring-cloud-stream with Apache License 2.0 | 6 votes |
@Test public void testSendJsonAsString() throws Exception { try (ConfigurableApplicationContext context = SpringApplication.run( SourceApplication.class, "--server.port=0", "--spring.jmx.enabled=false")) { MessageCollector collector = context.getBean(MessageCollector.class); Source source = context.getBean(Source.class); User user = new User("Alice"); String json = this.mapper.writeValueAsString(user); source.output().send(MessageBuilder.withPayload(user).build()); Message<String> message = (Message<String>) collector .forChannel(source.output()).poll(1, TimeUnit.SECONDS); assertThat( message.getHeaders().get(MessageHeaders.CONTENT_TYPE, MimeType.class) .includes(MimeTypeUtils.APPLICATION_JSON)); assertThat(json).isEqualTo(message.getPayload()); } }
Example #6
Source File: ContentTypeTests.java From spring-cloud-stream with Apache License 2.0 | 6 votes |
@Test public void testSendWithDefaultContentType() throws Exception { try (ConfigurableApplicationContext context = SpringApplication.run( SourceApplication.class, "--server.port=0", "--spring.jmx.enabled=false")) { MessageCollector collector = context.getBean(MessageCollector.class); Source source = context.getBean(Source.class); User user = new User("Alice"); source.output().send(MessageBuilder.withPayload(user).build()); Message<String> message = (Message<String>) collector .forChannel(source.output()).poll(1, TimeUnit.SECONDS); User received = this.mapper.readValue(message.getPayload(), User.class); assertThat( message.getHeaders().get(MessageHeaders.CONTENT_TYPE, MimeType.class) .includes(MimeTypeUtils.APPLICATION_JSON)); assertThat(user.getName()).isEqualTo(received.getName()); } }
Example #7
Source File: CustomPartitionedProducerTest.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
@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 #8
Source File: CustomPartitionedProducerTest.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
@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 #9
Source File: ContentTypeTests.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
@Test public void testSendBinaryDataWithContentType() throws Exception { try (ConfigurableApplicationContext context = SpringApplication.run( SourceApplication.class, "--server.port=0", "--spring.jmx.enabled=false", "--spring.cloud.stream.bindings.output.contentType=image/jpeg")) { MessageCollector collector = context.getBean(MessageCollector.class); Source source = context.getBean(Source.class); byte[] data = new byte[] { 0, 1, 2, 3 }; source.output().send(MessageBuilder.withPayload(data).build()); Message<byte[]> message = (Message<byte[]>) collector .forChannel(source.output()).poll(1, TimeUnit.SECONDS); assertThat(message.getPayload()).isEqualTo(data); } }
Example #10
Source File: GitterService.java From Hands-On-Reactive-Programming-in-Spring-5 with MIT License | 5 votes |
@StreamEmitter @Output(Source.OUTPUT) public Flux<MessageResponse> getMessagesStream() { return webClient.get() .uri(GitterUriBuilder.from(gitterProperties.getStream()) .build() .toUri()) .retrieve() .bodyToFlux(MessageResponse.class) .retryBackoff(Long.MAX_VALUE, Duration.ofMillis(500)); }
Example #11
Source File: GitterService.java From Hands-On-Reactive-Programming-in-Spring-5 with MIT License | 5 votes |
@SneakyThrows @StreamEmitter @Output(Source.OUTPUT) public Flux<MessageResponse> getLatestMessages() { return webClient.get() .uri(GitterUriBuilder.from(gitterProperties.getApi()) .build() .toUri()) .retrieve() .bodyToFlux(MessageResponse.class) .timeout(Duration.ofSeconds(1)) .retryBackoff(Long.MAX_VALUE, Duration.ofMillis(500)); }
Example #12
Source File: MessageChannelConfigurerTests.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
@Test public void testChannelTypes() throws Exception { DirectWithAttributesChannel inputChannel = (DirectWithAttributesChannel) this.testSink .input(); DirectWithAttributesChannel outputChannel = (DirectWithAttributesChannel) this.testSource .output(); assertThat(inputChannel.getAttribute("type")).isEqualTo(Sink.INPUT); assertThat(outputChannel.getAttribute("type")).isEqualTo(Source.OUTPUT); }
Example #13
Source File: NotificationPublisherImpl.java From event-store-demo with GNU General Public License v3.0 | 5 votes |
@Publisher( channel = Source.OUTPUT ) public Message<String> sendNotification( Tuple event ) { String payload = converter.convert( event ); return MessageBuilder .withPayload( payload ) .setHeader( "x-delay", 1000 ) .build(); }
Example #14
Source File: ReservationClientApplication.java From training with Apache License 2.0 | 5 votes |
@Bean RouterFunction<ServerResponse> routes(WebClient client, Source src) { return route(GET("/reservations/names"), req -> { Flux<String> names = client .get() .uri("http://reservation-service/reservations") .retrieve() .bodyToFlux(Reservation.class) .map(Reservation::getReservationName); Publisher<String> fallback = HystrixCommands .from(names) .commandName("reservation-names") .fallback(Flux.just("EEK!")) .eager() .build(); return ServerResponse.ok().body(fallback, String.class); }) .andRoute(POST("/reservations"), req -> { Flux<Boolean> sendResult = req.bodyToFlux(Reservation.class) .map(Reservation::getReservationName) .map(r -> MessageBuilder.withPayload(r).build()) .map(msg -> src.output().send(msg)); return ServerResponse.ok().body(sendResult, Boolean.class); } ); }
Example #15
Source File: SourceBindingWithGlobalPropertiesOnlyTest.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
@Test public void testGlobalPropertiesSet() { BindingProperties bindingProperties = this.bindingServiceProperties .getBindingProperties(Source.OUTPUT); Assertions.assertThat(bindingProperties.getContentType()) .isEqualTo("application/json"); Assertions.assertThat(bindingProperties.getProducer()).isNotNull(); Assertions.assertThat(bindingProperties.getProducer().getPartitionKeyExpression() .getExpressionString()).isEqualTo("key"); }
Example #16
Source File: ReservationClientApplication.java From training with Apache License 2.0 | 5 votes |
@Bean RouterFunction<ServerResponse> routes(WebClient client, Source src) { return route(GET("/reservations/names"), req -> { Flux<String> names = client .get() .uri("http://reservation-service/reservations") .retrieve() .bodyToFlux(Reservation.class) .map(Reservation::getReservationName); Publisher<String> fallback = HystrixCommands .from(names) .commandName("reservation-names") .fallback(Flux.just("EEK!")) .eager() .build(); return ServerResponse.ok().body(fallback, String.class); }) .andRoute(POST("/reservations"), req -> { Flux<Boolean> sendResult = req.bodyToFlux(Reservation.class) .map(Reservation::getReservationName) .map(r -> MessageBuilder.withPayload(r).build()) .map(msg -> src.output().send(msg)); return ServerResponse.ok().body(sendResult, Boolean.class); } ); }
Example #17
Source File: SourceBindingWithGlobalPropertiesTest.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
@Test public void testGlobalPropertiesSet() { BindingProperties bindingProperties = this.serviceProperties .getBindingProperties(Source.OUTPUT); Assertions.assertThat(bindingProperties.getContentType()) .isEqualTo("application/json"); Assertions.assertThat(bindingProperties.getDestination()).isEqualTo("ticktock"); Assertions.assertThat(bindingProperties.getProducer().getRequiredGroups()) .containsExactly("someGroup"); // default propagates to producer Assertions.assertThat(bindingProperties.getProducer().getPartitionCount()) .isEqualTo(4); // validates binding property takes precedence over default Assertions.assertThat(bindingProperties.getProducer().getHeaderMode()) .isEqualTo(HeaderMode.none); }
Example #18
Source File: CustomPartitionedProducerTest.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
@Test public void testCustomPartitionedProducer() { ApplicationContext context = SpringApplication.run( CustomPartitionedProducerTest.TestSource.class, "--spring.jmx.enabled=false", "--spring.main.web-application-type=none", "--spring.cloud.stream.bindings.output.producer.partitionKeyExtractorClass=" + "org.springframework.cloud.stream.partitioning.CustomPartitionKeyExtractorClass", "--spring.cloud.stream.bindings.output.producer.partitionSelectorClass=" + "org.springframework.cloud.stream.partitioning.CustomPartitionSelectorClass", "--spring.cloud.stream.default-binder=mock"); Source testSource = context.getBean(Source.class); DirectChannel messageChannel = (DirectChannel) testSource.output(); for (ChannelInterceptor channelInterceptor : messageChannel .getInterceptors()) { if (channelInterceptor instanceof MessageConverterConfigurer.PartitioningInterceptor) { Field partitionHandlerField = ReflectionUtils.findField( MessageConverterConfigurer.PartitioningInterceptor.class, "partitionHandler"); ReflectionUtils.makeAccessible(partitionHandlerField); PartitionHandler partitionHandler = (PartitionHandler) ReflectionUtils .getField(partitionHandlerField, channelInterceptor); Field partitonKeyExtractorField = ReflectionUtils.findField( PartitionHandler.class, "partitionKeyExtractorStrategy"); ReflectionUtils.makeAccessible(partitonKeyExtractorField); Field partitonSelectorField = ReflectionUtils .findField(PartitionHandler.class, "partitionSelectorStrategy"); ReflectionUtils.makeAccessible(partitonSelectorField); assertThat(((PartitionKeyExtractorStrategy) ReflectionUtils .getField(partitonKeyExtractorField, partitionHandler)).getClass() .equals(CustomPartitionKeyExtractorClass.class)).isTrue(); assertThat(((PartitionSelectorStrategy) ReflectionUtils .getField(partitonSelectorField, partitionHandler)).getClass() .equals(CustomPartitionSelectorClass.class)).isTrue(); } } }
Example #19
Source File: CustomPartitionedProducerTest.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
public void testCustomPartitionedProducerMultipleInstances() { ApplicationContext context = SpringApplication.run( CustomPartitionedProducerTest.TestSourceMultipleStrategies.class, "--spring.jmx.enabled=false", "--spring.main.web-application-type=none", "--spring.cloud.stream.bindings.output.producer.partitionKeyExtractorName=customPartitionKeyExtractorOne", "--spring.cloud.stream.bindings.output.producer.partitionSelectorName=customPartitionSelectorTwo", "--spring.cloud.stream.default-binder=mock"); Source testSource = context.getBean(Source.class); DirectChannel messageChannel = (DirectChannel) testSource.output(); for (ChannelInterceptor channelInterceptor : messageChannel .getInterceptors()) { if (channelInterceptor instanceof MessageConverterConfigurer.PartitioningInterceptor) { Field partitionHandlerField = ReflectionUtils.findField( MessageConverterConfigurer.PartitioningInterceptor.class, "partitionHandler"); ReflectionUtils.makeAccessible(partitionHandlerField); PartitionHandler partitionHandler = (PartitionHandler) ReflectionUtils .getField(partitionHandlerField, channelInterceptor); Field partitonKeyExtractorField = ReflectionUtils.findField( PartitionHandler.class, "partitionKeyExtractorStrategy"); ReflectionUtils.makeAccessible(partitonKeyExtractorField); Field partitonSelectorField = ReflectionUtils .findField(PartitionHandler.class, "partitionSelectorStrategy"); ReflectionUtils.makeAccessible(partitonSelectorField); assertThat(((PartitionKeyExtractorStrategy) ReflectionUtils .getField(partitonKeyExtractorField, partitionHandler)).getClass() .equals(CustomPartitionKeyExtractorClass.class)).isTrue(); assertThat(((PartitionSelectorStrategy) ReflectionUtils .getField(partitonSelectorField, partitionHandler)).getClass() .equals(CustomPartitionSelectorClass.class)).isTrue(); } } }
Example #20
Source File: CustomPartitionedProducerTest.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
@Test public void testCustomPartitionedProducerAsSingletons() { ApplicationContext context = SpringApplication.run( CustomPartitionedProducerTest.TestSource.class, "--spring.jmx.enabled=false", "--spring.main.web-application-type=none", "--spring.cloud.stream.default-binder=mock"); Source testSource = context.getBean(Source.class); DirectChannel messageChannel = (DirectChannel) testSource.output(); for (ChannelInterceptor channelInterceptor : messageChannel .getInterceptors()) { if (channelInterceptor instanceof MessageConverterConfigurer.PartitioningInterceptor) { Field partitionHandlerField = ReflectionUtils.findField( MessageConverterConfigurer.PartitioningInterceptor.class, "partitionHandler"); ReflectionUtils.makeAccessible(partitionHandlerField); PartitionHandler partitionHandler = (PartitionHandler) ReflectionUtils .getField(partitionHandlerField, channelInterceptor); Field partitonKeyExtractorField = ReflectionUtils.findField( PartitionHandler.class, "partitionKeyExtractorStrategy"); ReflectionUtils.makeAccessible(partitonKeyExtractorField); Field partitonSelectorField = ReflectionUtils .findField(PartitionHandler.class, "partitionSelectorStrategy"); ReflectionUtils.makeAccessible(partitonSelectorField); assertThat(((PartitionKeyExtractorStrategy) ReflectionUtils .getField(partitonKeyExtractorField, partitionHandler)).getClass() .equals(CustomPartitionKeyExtractorClass.class)).isTrue(); assertThat(((PartitionSelectorStrategy) ReflectionUtils .getField(partitonSelectorField, partitionHandler)).getClass() .equals(CustomPartitionSelectorClass.class)).isTrue(); } } }
Example #21
Source File: CustomPartitionedProducerTest.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
@Test public void testCustomPartitionedProducerByName() { ApplicationContext context = SpringApplication.run( CustomPartitionedProducerTest.TestSource.class, "--spring.jmx.enabled=false", "--spring.main.web-application-type=none", "--spring.cloud.stream.bindings.output.producer.partitionKeyExtractorName=customPartitionKeyExtractor", "--spring.cloud.stream.bindings.output.producer.partitionSelectorName=customPartitionSelector", "--spring.cloud.stream.default-binder=mock"); Source testSource = context.getBean(Source.class); DirectChannel messageChannel = (DirectChannel) testSource.output(); for (ChannelInterceptor channelInterceptor : messageChannel .getInterceptors()) { if (channelInterceptor instanceof MessageConverterConfigurer.PartitioningInterceptor) { Field partitionHandlerField = ReflectionUtils.findField( MessageConverterConfigurer.PartitioningInterceptor.class, "partitionHandler"); ReflectionUtils.makeAccessible(partitionHandlerField); PartitionHandler partitionHandler = (PartitionHandler) ReflectionUtils .getField(partitionHandlerField, channelInterceptor); Field partitonKeyExtractorField = ReflectionUtils.findField( PartitionHandler.class, "partitionKeyExtractorStrategy"); ReflectionUtils.makeAccessible(partitonKeyExtractorField); Field partitonSelectorField = ReflectionUtils .findField(PartitionHandler.class, "partitionSelectorStrategy"); ReflectionUtils.makeAccessible(partitonSelectorField); assertThat(((PartitionKeyExtractorStrategy) ReflectionUtils .getField(partitonKeyExtractorField, partitionHandler)).getClass() .equals(CustomPartitionKeyExtractorClass.class)).isTrue(); assertThat(((PartitionSelectorStrategy) ReflectionUtils .getField(partitonSelectorField, partitionHandler)).getClass() .equals(CustomPartitionSelectorClass.class)).isTrue(); } } }
Example #22
Source File: GreenfieldFunctionEnableBindingTests.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
@Bean public HttpRequestHandlingEndpointSupport doFoo(Source source) { HttpRequestHandlerEndpointSpec httpRequestHandler = Http .inboundChannelAdapter("/*") .requestMapping(requestMapping -> requestMapping .methods(HttpMethod.POST).consumes("*/*")) .requestChannel(source.output()); return httpRequestHandler.get(); }
Example #23
Source File: SourceToFunctionsSupportTests.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
@Bean public IntegrationFlow messageSourceFlow(Source source) { Supplier<Message<String>> messageSource = () -> MessageBuilder .withPayload("hello function") .setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN) .build(); return IntegrationFlows.from(messageSource).channel(source.output()).get(); }
Example #24
Source File: SubscribableChannelBindingTargetFactory.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
@Override public SubscribableChannel createOutput(String name) { DirectWithAttributesChannel subscribableChannel = new DirectWithAttributesChannel(); subscribableChannel.setComponentName(name); subscribableChannel.setAttribute("type", Source.OUTPUT); this.messageChannelConfigurer.configureOutputChannel(subscribableChannel, name); if (context != null && !context.containsBean(name)) { context.registerBean(name, DirectWithAttributesChannel.class, () -> subscribableChannel); } return subscribableChannel; }
Example #25
Source File: SpringCloudStreamAwsApplicationsITCase.java From spring-cloud-stream-app-starters with Apache License 2.0 | 5 votes |
@Test public void testS3Source() throws IOException, InterruptedException { String bucket = "TestBucket"; String key = "foo"; String content = "Spring Cloud Stream AWS S3 Source test"; this.applicationContext = SpringApplication.run(S3SourceBootConfiguration.class, "--s3.remoteDir=" + bucket, "--file.consumer.mode=lines", "--file.consumer.with-markers=false"); ResourceIdResolver resourceIdResolver = this.applicationContext.getBean(ResourceIdResolver.class); AmazonS3 amazonS3 = this.applicationContext.getBean(AmazonS3.class); ObjectMetadata objectMetadata = new ObjectMetadata(); objectMetadata.setContentLength(content.length()); String bucketName = resourceIdResolver.resolveToPhysicalResourceId(bucket); amazonS3.putObject(bucketName, key, new ByteArrayInputStream(content.getBytes("UTF-8")), objectMetadata); try { Source source = this.applicationContext.getBean(Source.class); MessageCollector messageCollector = this.applicationContext.getBean(MessageCollector.class); Message<?> received = messageCollector.forChannel(source.output()).poll(10, TimeUnit.SECONDS); assertNotNull(received); assertThat(received, hasHeader(FileHeaders.FILENAME, key)); assertThat(received, hasPayload("Spring Cloud Stream AWS S3 Source test")); } finally { amazonS3.deleteObject(bucketName, key); } }
Example #26
Source File: MailSourceConfiguration.java From spring-cloud-stream-app-starters with Apache License 2.0 | 5 votes |
@Bean public IntegrationFlow mailInboundFlow() { return getFlowBuilder() .transform(Transformers.fromMail(this.properties.getCharset())) .channel(Source.OUTPUT) .get(); }
Example #27
Source File: AmazonS3SourceConfiguration.java From spring-cloud-stream-app-starters with Apache License 2.0 | 5 votes |
@Bean public IntegrationFlow s3InboundFlow(FileConsumerProperties fileConsumerProperties, S3InboundFileSynchronizer s3InboundFileSynchronizer) { S3InboundFileSynchronizingMessageSource s3MessageSource = new S3InboundFileSynchronizingMessageSource(s3InboundFileSynchronizer); s3MessageSource.setLocalDirectory(this.s3SourceProperties.getLocalDir()); s3MessageSource.setAutoCreateLocalDirectory(this.s3SourceProperties.isAutoCreateLocalDir()); return FileUtils.enhanceFlowForReadingMode(IntegrationFlows.from(s3MessageSource), fileConsumerProperties) .channel(Source.OUTPUT) .get(); }
Example #28
Source File: MqttSourceConfiguration.java From mqtt with Apache License 2.0 | 5 votes |
@Bean public MqttPahoMessageDrivenChannelAdapter mqttInbound() { MqttPahoMessageDrivenChannelAdapter adapter = new MqttPahoMessageDrivenChannelAdapter(properties.getClientId(), mqttClientFactory, properties.getTopics()); adapter.setQos(properties.getQos()); adapter.setConverter(pahoMessageConverter()); adapter.setOutputChannelName(Source.OUTPUT); return adapter; }
Example #29
Source File: LoggregatorSourceConfiguration.java From spring-cloud-stream-app-starters with Apache License 2.0 | 5 votes |
@Bean public LoggregatorMessageSource loggregatorMessageSource( @Qualifier(Source.OUTPUT) MessageChannel source, CloudFoundryClient cloudFoundryClient) { return new LoggregatorMessageSource( this.loggregatorSourceProperties.getApplicationName(), cloudFoundryClient, source); }
Example #30
Source File: SignificantStockChangeSourceApplication.java From Mastering-Spring-5.0 with MIT License | 5 votes |
@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(); }; }