Java Code Examples for org.springframework.cloud.stream.annotation.Input

The following examples show how to use org.springframework.cloud.stream.annotation.Input. 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_io_2019   Source File: ScsApplication.java    License: Apache License 2.0 6 votes vote down vote up
@StreamListener
@SendTo(Bindings.RATED_MOVIES)
KStream<Long, RatedMovie> rateMoviesFor(@Input(Bindings.AVG_TABLE) KTable<Long, Double> ratings,
                                        @Input(Bindings.MOVIES) KTable<Long, Movie> movies) {

  ValueJoiner<Movie, Double, RatedMovie> joiner = (movie, rating) ->
      new RatedMovie(movie.getMovieId(), movie.getReleaseYear(), movie.getTitle(), rating);

  movies
      .join(ratings, joiner, Materialized
          .<Long, RatedMovie, KeyValueStore<Bytes, byte[]>>as(Bindings.RATED_MOVIES_STORE)
          .withKeySerde(Serdes.Long())
          .withValueSerde(new JsonSerde<>(RatedMovie.class)));

  return movies.join(ratings, joiner).toStream();
}
 
Example 2
Source Project: spring_io_2019   Source File: ScsApplication.java    License: Apache License 2.0 5 votes vote down vote up
@StreamListener
@SendTo(Bindings.AVG_RATINGS)
KStream<Long, Double> averageRatingsFor(@Input(Bindings.RATINGS) KStream<Long, Rating> ratings) {
  KGroupedStream<Long, Double> ratingsGrouped =
      ratings
          .mapValues(Rating::getRating)
          .groupByKey();
  KTable<Long, Long> count = ratingsGrouped.count();
  KTable<Long, Double>
      reduce = ratingsGrouped.reduce(Double::sum, Materialized.with(Serdes.Long(), Serdes.Double()));
  KTable<Long, Double>
      join = reduce.join(count, (sum, count1) -> sum / count1, Materialized.with(Serdes.Long(), Serdes.Double()));
  return join.toStream();
}
 
Example 3
Source Project: springboot-kafka-avro   Source File: KafkaStreamsApp.java    License: MIT License 5 votes vote down vote up
@StreamListener
@SendTo(USERS_FILTERED)
KStream<String, User> processUsers(@Input(USERS) KStream<String, User> inputStream) {
  return inputStream
      .filter((key, user) -> user.getAge() < 40)
      .mapValues(user -> new User(user.getName().toUpperCase(), user.getAge()))
      .peek((key, user) -> log.info("New entry in filtered stream => Key = " + key + " Value = " + user));
}
 
Example 4
@StreamListener
@Output(Processor.OUTPUT)
public Flux<Comment> save(@Input(Processor.INPUT) Flux<Comment> newComment) {
	return repository
		.saveAll(newComment)
		.map(comment -> {
			meterRegistry
				.counter("comments.consumed", "imageId", comment.getImageId())
				.increment();
			return comment;
		});
}
 
Example 5
@StreamListener
@Output(Processor.OUTPUT)
public Flux<Void> save(@Input(Processor.INPUT) Flux<Comment> newComment) {
	return repository
		.saveAll(newComment)
		.flatMap(comment -> {
			meterRegistry
				.counter("comments.consumed", "imageId", comment.getImageId())
				.increment();
			return Mono.empty();
		});
}
 
Example 6
@StreamListener
@Output(Processor.OUTPUT)
public Flux<Void> save(@Input(Processor.INPUT) Flux<Comment> newComment) {
	return repository
		.saveAll(newComment)
		.flatMap(comment -> {
			meterRegistry
				.counter("comments.consumed", "imageId", comment.getImageId())
				.increment();
			return Mono.empty();
		});
}
 
Example 7
@StreamListener
public void process(@Input(Sink.INPUT) Flux<String> names) {
		names
			.map(Author::new)
			.flatMap(this.repository::save)
			.subscribe(saved -> System.out.println("saved " + saved.toString() + '.'));
}
 
Example 8
Source Project: training   Source File: ReservationServiceApplication.java    License: Apache License 2.0 5 votes vote down vote up
@StreamListener
public void incomingMessages(@Input(Sink.INPUT) Flux<String> rnPublisher) {
	rnPublisher
			.map(rn -> new Reservation(null, rn))
			.flatMap(this.rr::save)
			.subscribe(r -> System.out.println("received and saved " + r.getId() + " with " + r.getReservationName() + "."));
}
 
Example 9
Source Project: training   Source File: ReservationServiceApplication.java    License: Apache License 2.0 5 votes vote down vote up
@StreamListener
public void incomingMessages(@Input(Sink.INPUT) Flux<String> rnPublisher) {
	rnPublisher
			.map(rn -> new Reservation(null, rn))
			.flatMap(this.rr::save)
			.subscribe(r -> System.out.println("received and saved " + r.getId() + " with " + r.getReservationName() + "."));
}
 
Example 10
Source Project: Spring-5.0-Cookbook   Source File: EmpIdConverterConverter.java    License: MIT License 5 votes vote down vote up
@StreamListener
@Output(Processor.OUTPUT)
public Flux<String> verifyEmpString(@Input(Processor.INPUT) Flux<String> id) {
	System.out.println("first");
	id.delayElements(Duration.ofMillis(2))
	   .log();
	return id;
}
 
Example 11
@StreamListener
@Output(Processor.OUTPUT)
public Flux<Comment> save(@Input(Processor.INPUT) Flux<Comment> newComment) {
	return repository
		.saveAll(newComment)
		.map(comment -> {
			meterRegistry
				.counter("comments.consumed", "imageId", comment.getImageId())
				.increment();
			return comment;
		});
}
 
Example 12
@Input(APPLICATIONS_IN)
SubscribableChannel sourceOfLoanApplications();
 
Example 13
@Input(BOOKING_ORDER_INPUT)
MessageChannel bookingOrderInput();
 
Example 14
@Input(BILLING_INPUT)
MessageChannel billingInput();
 
Example 15
@Input(BOOKING_ORDER_INPUT)
MessageChannel bookingOrderInput();
 
Example 16
Source Project: MyShopPlus   Source File: AdminLoginLogSink.java    License: Apache License 2.0 4 votes vote down vote up
@Input("admin-login-log-topic")
SubscribableChannel adminLoginLog();
 
Example 17
Source Project: spring-boot-demo   Source File: MySource.java    License: MIT License 4 votes vote down vote up
@Input("input1")
SubscribableChannel input1();
 
Example 18
Source Project: spring-boot-demo   Source File: MySource.java    License: MIT License 4 votes vote down vote up
@Input("input2")
SubscribableChannel input2();
 
Example 19
Source Project: spring-boot-demo   Source File: MySource.java    License: MIT License 4 votes vote down vote up
@Input("input3")
SubscribableChannel input3();
 
Example 20
Source Project: microservices-platform   Source File: RocketMqConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Input(Sink.INPUT)
SubscribableChannel input();
 
Example 21
Source Project: microservices-platform   Source File: RocketMqConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Input("input2")
SubscribableChannel input2();
 
Example 22
@Input(BOOKING_ORDER_INPUT)
MessageChannel bookingOrderInput();
 
Example 23
Source Project: microservices-platform   Source File: RocketMqConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Input(Sink.INPUT)
SubscribableChannel input();
 
Example 24
@Input
SubscribableChannel scoringPositiveIn();
 
Example 25
Source Project: spring-cloud-study   Source File: MyProcessor.java    License: Apache License 2.0 4 votes vote down vote up
@Input(LOG_FORMAT_INPUT)
SubscribableChannel logFormatInput();
 
Example 26
@Input(NEW_COMMENTS)
SubscribableChannel newComments();
 
Example 27
Source Project: Dodder   Source File: MessageStreams.java    License: MIT License 4 votes vote down vote up
@Input("torrent-message-in")
MessageChannel torrentMessageInput();
 
Example 28
Source Project: Dodder   Source File: MessageStreams.java    License: MIT License 4 votes vote down vote up
@Input("index-message-in")
MessageChannel indexMessageInput();
 
Example 29
Source Project: microservices-springboot   Source File: ProductInputChannel.java    License: MIT License 4 votes vote down vote up
@Input(PRODUCT_DELETED_INPUT)
SubscribableChannel productDeletedInput();
 
Example 30
Source Project: hello-spring-cloud-alibaba   Source File: MySink.java    License: MIT License 4 votes vote down vote up
@Input("input1")
SubscribableChannel input1();