org.springframework.cloud.stream.annotation.Output Java Examples
The following examples show how to use
org.springframework.cloud.stream.annotation.Output.
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: StreamListenerMessageArgumentTests.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
@StreamListener(Processor.INPUT) @Output(Processor.OUTPUT) public StreamListenerTestUtils.BarPojo receive(Message<String> fooMessage) { this.receivedMessages.add(fooMessage); StreamListenerTestUtils.BarPojo barPojo = new StreamListenerTestUtils.BarPojo(); barPojo.setBar(fooMessage.getPayload()); return barPojo; }
Example #2
Source File: StreamListenerMethodWithReturnMessageTests.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
@StreamListener(Processor.INPUT) @Output(Processor.OUTPUT) public Message<?> receive(StreamListenerTestUtils.FooPojo fooPojo) { this.receivedPojos.add(fooPojo); StreamListenerTestUtils.BarPojo bazPojo = new StreamListenerTestUtils.BarPojo(); bazPojo.setBar(fooPojo.getFoo()); return MessageBuilder.withPayload(bazPojo).setHeader("foo", "bar").build(); }
Example #3
Source File: CommentService.java From Learning-Spring-Boot-2.0-Second-Edition with MIT License | 5 votes |
@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 #4
Source File: CommentService.java From Learning-Spring-Boot-2.0-Second-Edition with MIT License | 5 votes |
@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
Source File: StreamListenerAnnotationBeanPostProcessor.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
private boolean checkDeclarativeMethod(Method method, String methodAnnotatedInboundName, String methodAnnotatedOutboundName) { int methodArgumentsLength = method.getParameterTypes().length; for (int parameterIndex = 0; parameterIndex < methodArgumentsLength; parameterIndex++) { MethodParameter methodParameter = MethodParameter.forExecutable(method, parameterIndex); if (methodParameter.hasParameterAnnotation(Input.class)) { String inboundName = (String) AnnotationUtils.getValue( methodParameter.getParameterAnnotation(Input.class)); Assert.isTrue(StringUtils.hasText(inboundName), StreamListenerErrorMessages.INVALID_INBOUND_NAME); Assert.isTrue( isDeclarativeMethodParameter(inboundName, methodParameter), StreamListenerErrorMessages.INVALID_DECLARATIVE_METHOD_PARAMETERS); return true; } else if (methodParameter.hasParameterAnnotation(Output.class)) { String outboundName = (String) AnnotationUtils.getValue( methodParameter.getParameterAnnotation(Output.class)); Assert.isTrue(StringUtils.hasText(outboundName), StreamListenerErrorMessages.INVALID_OUTBOUND_NAME); Assert.isTrue( isDeclarativeMethodParameter(outboundName, methodParameter), StreamListenerErrorMessages.INVALID_DECLARATIVE_METHOD_PARAMETERS); return true; } else if (StringUtils.hasText(methodAnnotatedOutboundName)) { return isDeclarativeMethodParameter(methodAnnotatedOutboundName, methodParameter); } else if (StringUtils.hasText(methodAnnotatedInboundName)) { return isDeclarativeMethodParameter(methodAnnotatedInboundName, methodParameter); } } return false; }
Example #6
Source File: BindingBeanDefinitionRegistryUtils.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
public static void registerOutputBindingTargetBeanDefinition(String qualifierValue, String name, String bindingTargetInterfaceBeanName, String bindingTargetInterfaceMethodName, BeanDefinitionRegistry registry) { registerBindingTargetBeanDefinition(Output.class, qualifierValue, name, bindingTargetInterfaceBeanName, bindingTargetInterfaceMethodName, registry); }
Example #7
Source File: CommentService.java From Learning-Spring-Boot-2.0-Second-Edition with MIT License | 5 votes |
@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 #8
Source File: CommentService.java From Learning-Spring-Boot-2.0-Second-Edition with MIT License | 5 votes |
@StreamListener @Output(Processor.OUTPUT) public Flux<Comment> save(@Input(Processor.INPUT) Flux<Comment> newComment) { return repository .saveAll(newComment) .map(comment -> { log.info("Saving new comment " + comment); meterRegistry .counter("comments.consumed", "imageId", comment.getImageId()) .increment(); return comment; }); }
Example #9
Source File: StreamListenerWithAnnotatedInputOutputArgsTests.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
@StreamListener public void receive(@Input(Processor.INPUT) SubscribableChannel input, @Output(Processor.OUTPUT) final MessageChannel output) { input.subscribe(new MessageHandler() { @Override public void handleMessage(Message<?> message) throws MessagingException { output.send(MessageBuilder .withPayload(message.getPayload().toString().toUpperCase()) .build()); } }); }
Example #10
Source File: StreamListenerWithAnnotatedInputOutputArgsTests.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
@StreamListener public void receive(@Input("invalid") SubscribableChannel input, @Output(Processor.OUTPUT) final MessageChannel output) { input.subscribe(new MessageHandler() { @Override public void handleMessage(Message<?> message) throws MessagingException { output.send(MessageBuilder .withPayload(message.getPayload().toString().toUpperCase()) .build()); } }); }
Example #11
Source File: StreamListenerWithAnnotatedInputOutputArgsTests.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
@StreamListener public void receive(@Input(Processor.INPUT) SubscribableChannel input, @Output(Processor.OUTPUT) final MessageChannel output, String someArg) { input.subscribe(new MessageHandler() { @Override public void handleMessage(Message<?> message) throws MessagingException { output.send(MessageBuilder .withPayload(message.getPayload().toString().toUpperCase()) .build()); } }); }
Example #12
Source File: CommentService.java From Learning-Spring-Boot-2.0-Second-Edition with MIT License | 5 votes |
@StreamListener @Output(CustomProcessor.OUTPUT) public Flux<Void> save(@Input(CustomProcessor.INPUT) Flux<Comment> newComments) { return repository .saveAll(newComments) .flatMap(comment -> { meterRegistry .counter("comments.consumed", "imageId", comment.getImageId()) .increment(); return Mono.empty(); }); }
Example #13
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 #14
Source File: EmpIdConverterConverter.java From Spring-5.0-Cookbook with MIT License | 5 votes |
@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 #15
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 #16
Source File: StreamListenerHandlerBeanTests.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
@StreamListener(Processor.INPUT) @Output(Processor.OUTPUT) public StreamListenerTestUtils.BarPojo receive( StreamListenerTestUtils.FooPojo fooMessage) { this.receivedPojos.add(fooMessage); StreamListenerTestUtils.BarPojo barPojo = new StreamListenerTestUtils.BarPojo(); barPojo.setBar(fooMessage.getFoo()); return barPojo; }
Example #17
Source File: CommentController.java From Learning-Spring-Boot-2.0-Second-Edition with MIT License | 4 votes |
@StreamEmitter @Output(Source.OUTPUT) public void emit(FluxSender output) { output.send(this.flux); }
Example #18
Source File: StreamListenerHandlerMethodTests.java From spring-cloud-stream with Apache License 2.0 | 4 votes |
@StreamListener public void receive(@Input(Processor.INPUT) SubscribableChannel input, @Output("invalid") MessageChannel output) { }
Example #19
Source File: StreamListenerMethodUtils.java From spring-cloud-stream with Apache License 2.0 | 4 votes |
protected static void validateStreamListenerMethod(Method method, int inputAnnotationCount, int outputAnnotationCount, String methodAnnotatedInboundName, String methodAnnotatedOutboundName, boolean isDeclarative, String condition) { int methodArgumentsLength = method.getParameterTypes().length; if (!isDeclarative) { Assert.isTrue(inputAnnotationCount == 0 && outputAnnotationCount == 0, StreamListenerErrorMessages.INVALID_DECLARATIVE_METHOD_PARAMETERS); } if (StringUtils.hasText(methodAnnotatedInboundName) && StringUtils.hasText(methodAnnotatedOutboundName)) { Assert.isTrue(inputAnnotationCount == 0 && outputAnnotationCount == 0, StreamListenerErrorMessages.INVALID_INPUT_OUTPUT_METHOD_PARAMETERS); } if (StringUtils.hasText(methodAnnotatedInboundName)) { Assert.isTrue(inputAnnotationCount == 0, StreamListenerErrorMessages.INVALID_INPUT_VALUES); Assert.isTrue(outputAnnotationCount == 0, StreamListenerErrorMessages.INVALID_INPUT_VALUE_WITH_OUTPUT_METHOD_PARAM); } else { Assert.isTrue(inputAnnotationCount >= 1, StreamListenerErrorMessages.NO_INPUT_DESTINATION); } if (StringUtils.hasText(methodAnnotatedOutboundName)) { Assert.isTrue(outputAnnotationCount == 0, StreamListenerErrorMessages.INVALID_OUTPUT_VALUES); } if (!Void.TYPE.equals(method.getReturnType())) { Assert.isTrue(!StringUtils.hasText(condition), StreamListenerErrorMessages.CONDITION_ON_METHOD_RETURNING_VALUE); } if (isDeclarative) { Assert.isTrue(!StringUtils.hasText(condition), StreamListenerErrorMessages.CONDITION_ON_DECLARATIVE_METHOD); for (int parameterIndex = 0; parameterIndex < methodArgumentsLength; parameterIndex++) { MethodParameter methodParameter = MethodParameter.forExecutable(method, parameterIndex); if (methodParameter.hasParameterAnnotation(Input.class)) { String inboundName = (String) AnnotationUtils.getValue( methodParameter.getParameterAnnotation(Input.class)); Assert.isTrue(StringUtils.hasText(inboundName), StreamListenerErrorMessages.INVALID_INBOUND_NAME); } if (methodParameter.hasParameterAnnotation(Output.class)) { String outboundName = (String) AnnotationUtils.getValue( methodParameter.getParameterAnnotation(Output.class)); Assert.isTrue(StringUtils.hasText(outboundName), StreamListenerErrorMessages.INVALID_OUTBOUND_NAME); } } if (methodArgumentsLength > 1) { Assert.isTrue( inputAnnotationCount + outputAnnotationCount == methodArgumentsLength, StreamListenerErrorMessages.INVALID_DECLARATIVE_METHOD_PARAMETERS); } } if (!method.getReturnType().equals(Void.TYPE)) { if (!StringUtils.hasText(methodAnnotatedOutboundName)) { if (outputAnnotationCount == 0) { throw new IllegalArgumentException( StreamListenerErrorMessages.RETURN_TYPE_NO_OUTBOUND_SPECIFIED); } Assert.isTrue((outputAnnotationCount == 1), StreamListenerErrorMessages.RETURN_TYPE_MULTIPLE_OUTBOUND_SPECIFIED); } } }
Example #20
Source File: TestSourceOutput.java From spring-cloud-gray with Apache License 2.0 | 4 votes |
@Output(OUTPUT) MessageChannel output();
Example #21
Source File: ProductCompositeIntegration.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 4 votes |
@Output(OUTPUT_RECOMMENDATIONS) MessageChannel outputRecommendations();
Example #22
Source File: Sender.java From Microservices-Building-Scalable-Software with MIT License | 4 votes |
@Output("checkInQ") public MessageChannel checkInQ();
Example #23
Source File: BatchEventAutoConfiguration.java From spring-cloud-task with Apache License 2.0 | 4 votes |
@Output(JOB_EXECUTION_EVENTS) MessageChannel jobExecutionEvents();
Example #24
Source File: ProductCompositeIntegration.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 4 votes |
@Output(OUTPUT_PRODUCTS) MessageChannel outputProducts();
Example #25
Source File: RocketMqConfig.java From microservices-platform with Apache License 2.0 | 4 votes |
@Output(Source.OUTPUT) MessageChannel output();
Example #26
Source File: ProductCompositeIntegration.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 4 votes |
@Output(OUTPUT_REVIEWS) MessageChannel outputReviews();
Example #27
Source File: KinesisBinderProcessorTests.java From spring-cloud-stream-binder-aws-kinesis with Apache License 2.0 | 4 votes |
@Output(TO_PROCESSOR_OUTPUT) MessageChannel toProcessorOutput();
Example #28
Source File: ConsumerProducerTransactionTests.java From spring-cloud-stream-binder-kafka with Apache License 2.0 | 4 votes |
@Output MessageChannel output2();
Example #29
Source File: ProductCompositeIntegration.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 4 votes |
@Output(OUTPUT_RECOMMENDATIONS) MessageChannel outputRecommendations();
Example #30
Source File: ProductCompositeIntegration.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 4 votes |
@Output(OUTPUT_REVIEWS) MessageChannel outputReviews();