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

The following examples show how to use org.springframework.cloud.stream.annotation.Output. 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
@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 2
@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 3
@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
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 5
public static void registerOutputBindingTargetBeanDefinition(String qualifierValue,
		String name, String bindingTargetInterfaceBeanName,
		String bindingTargetInterfaceMethodName, BeanDefinitionRegistry registry) {
	registerBindingTargetBeanDefinition(Output.class, qualifierValue, name,
			bindingTargetInterfaceBeanName, bindingTargetInterfaceMethodName,
			registry);
}
 
Example 6
@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 7
@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 8
@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 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 10
@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 11
@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 12
@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 13
@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 14
@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 15
@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
@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 17
@Output(APPROVED_OUT)
MessageChannel approved();
 
Example 18
@Output(DECLINED_OUT)
MessageChannel declined();
 
Example 19
@Output(BILLING_OUTPUT)
MessageChannel billingOutput();
 
Example 20
@Output(BOOKING_ORDER_OUTPUT)
MessageChannel bookingOrderOutput();
 
Example 21
Source Project: MyShopPlus   Source File: MessageSource.java    License: Apache License 2.0 4 votes vote down vote up
@Output("admin-login-log-topic")
MessageChannel adminLoginLog();
 
Example 22
@Output
MessageChannel purchases();
 
Example 23
Source Project: spring-boot-demo   Source File: MySource.java    License: MIT License 4 votes vote down vote up
@Output("output2")
MessageChannel output2();
 
Example 24
Source Project: microservices-platform   Source File: RocketMqConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Output(Source.OUTPUT)
MessageChannel output();
 
Example 25
Source Project: spring-cloud-study   Source File: MyProcessor.java    License: Apache License 2.0 4 votes vote down vote up
@Output(MESSAGE_OUTPUT)
MessageChannel logOutput();
 
Example 26
Source Project: myfeed   Source File: UserBinder.java    License: Apache License 2.0 4 votes vote down vote up
@Output(UserBinder.USER_INITIALIZED)
MessageChannel userinitialized();
 
Example 27
Source Project: microservices-springboot   Source File: ProductOutputChannel.java    License: MIT License 4 votes vote down vote up
@Output(PRODUCT_DELETED_OUTPUT)
MessageChannel productDeletedOutput();
 
Example 28
@Output("output2")
MessageChannel output2();
 
Example 29
@Output(SKIP_EVENTS)
MessageChannel skipEvents();
 
Example 30
Source Project: hello-spring-cloud-alibaba   Source File: MySource.java    License: MIT License 4 votes vote down vote up
@Output("output3")
MessageChannel output3();