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

The following examples show how to use org.springframework.cloud.stream.annotation.Input. 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: ScsApplication.java    From spring_io_2019 with Apache License 2.0 7 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 File: CommentService.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 5 votes vote down vote up
@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 #3
Source File: ScsApplication.java    From spring_io_2019 with 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 #4
Source File: CommentService.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 5 votes vote down vote up
@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 #5
Source File: KafkaStreamsApp.java    From springboot-kafka-avro with 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 #6
Source File: KafkaListenerConfiguration.java    From reactive-spring-online-training with Apache License 2.0 5 votes vote down vote up
@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 #7
Source File: ReservationServiceApplication.java    From training with 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 #8
Source File: ReservationServiceApplication.java    From training with 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 File: CommentService.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 5 votes vote down vote up
@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 #10
Source File: CommentService.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 5 votes vote down vote up
@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 #11
Source File: EmpIdConverterConverter.java    From Spring-5.0-Cookbook with 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 #12
Source File: Receiver.java    From if1007 with MIT License 4 votes vote down vote up
@Input("inventoryQ")
public MessageChannel inventoryQ();
 
Example #13
Source File: CreditDecisionChannels.java    From event-driven-spring-boot with Apache License 2.0 4 votes vote down vote up
@Input
SubscribableChannel customerCreatedIn();
 
Example #14
Source File: ChatServiceStreams.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 4 votes vote down vote up
@Input(NEW_COMMENTS)
SubscribableChannel newComments();
 
Example #15
Source File: ApplicationProcessChannels.java    From event-driven-spring-boot with Apache License 2.0 4 votes vote down vote up
@Input
SubscribableChannel customerCreatedIn();
 
Example #16
Source File: RocketMQConsumerApplication.java    From spring-cloud-alibaba with Apache License 2.0 4 votes vote down vote up
@Input("input4")
SubscribableChannel input4();
 
Example #17
Source File: CustomInput.java    From demo-project with MIT License 4 votes vote down vote up
@Input("customInput")
SubscribableChannel in();
 
Example #18
Source File: ChatServiceStreams.java    From Learning-Spring-Boot-2.0-Second-Edition with MIT License 4 votes vote down vote up
@Input(BROKER_TO_CLIENT)
SubscribableChannel brokerToClient();
 
Example #19
Source File: EventNotificationChannel.java    From Software-Architecture-with-Spring-5.0 with MIT License 4 votes vote down vote up
@Input
SubscribableChannel subscriptionOnMoneyTransferredChannel();
 
Example #20
Source File: EventNotificationChannel.java    From Software-Architecture-with-Spring-5.0 with MIT License 4 votes vote down vote up
@Input
SubscribableChannel subscriptionOnMoneyTransferredChannel();
 
Example #21
Source File: EventNotificationChannel.java    From Software-Architecture-with-Spring-5.0 with MIT License 4 votes vote down vote up
@Input
SubscribableChannel subscriptionOnMoneyTransferredChannel();
 
Example #22
Source File: ApplicationProcessChannels.java    From event-driven-spring-boot with Apache License 2.0 4 votes vote down vote up
@Input
SubscribableChannel creditApplicationDeclinedIn();
 
Example #23
Source File: SampleSink.java    From spring-cloud with Apache License 2.0 4 votes vote down vote up
@Input(INPUT1)
SubscribableChannel input1();
 
Example #24
Source File: PubSubExtendedBindingsPropertiesTests.java    From spring-cloud-gcp with Apache License 2.0 4 votes vote down vote up
@Input("custom-in")
SubscribableChannel customIn();
 
Example #25
Source File: ApplicationProcessChannels.java    From event-driven-spring-boot with Apache License 2.0 4 votes vote down vote up
@Input
SubscribableChannel creditApplicationEnteredIn();
 
Example #26
Source File: TestSink.java    From Lottor with MIT License 4 votes vote down vote up
@Input(INPUT)
SubscribableChannel input();
 
Example #27
Source File: Receiver.java    From Learning-Path-Spring-5-End-to-End-Programming with MIT License 4 votes vote down vote up
@Input("inventoryQ")
public MessageChannel inventoryQ();
 
Example #28
Source File: EventNotificationChannel.java    From Software-Architecture-with-Spring-5.0 with MIT License 4 votes vote down vote up
@Input
SubscribableChannel subscriptionOnMoneyTransferredChannel();
 
Example #29
Source File: Receiver.java    From Learning-Path-Spring-5-End-to-End-Programming with MIT License 4 votes vote down vote up
@Input("inventoryQ")
public MessageChannel inventoryQ();
 
Example #30
Source File: Receiver.java    From Learning-Path-Spring-5-End-to-End-Programming with MIT License 4 votes vote down vote up
@Input("checkInQ")
public MessageChannel checkInQ();