Java Code Examples for org.springframework.cloud.stream.messaging.Processor#INPUT

The following examples show how to use org.springframework.cloud.stream.messaging.Processor#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: StreamListenerAnnotatedMethodArgumentsTests.java    From spring-cloud-stream with Apache License 2.0 5 votes vote down vote up
@StreamListener
public void receive(
		@Input(Processor.INPUT) @Payload StreamListenerTestUtils.FooPojo fooPojo,
		@Headers Map<String, Object> headers,
		@Header(MessageHeaders.CONTENT_TYPE) String contentType) {
	this.receivedArguments.add(fooPojo);
	this.receivedArguments.add(headers);
	this.receivedArguments.add(contentType);
}
 
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<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
Source File: StreamListenerAnnotatedMethodArgumentsTests.java    From spring-cloud-stream with Apache License 2.0 5 votes vote down vote up
@StreamListener(Processor.INPUT)
public void receive(@Payload StreamListenerTestUtils.FooPojo fooPojo,
		@Headers Map<String, Object> headers,
		@Header(MessageHeaders.CONTENT_TYPE) String contentType) {
	this.receivedArguments.add(fooPojo);
	this.receivedArguments.add(headers);
	this.receivedArguments.add(contentType);
}
 
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<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: ContentTypeTckTests.java    From spring-cloud-stream with Apache License 2.0 5 votes vote down vote up
@StreamListener(Processor.INPUT)
@SendTo(Processor.OUTPUT)
public Person echo(Object value) throws Exception {
	ObjectMapper mapper = new ObjectMapper();
	// assume it is string because CT is text/plain
	return mapper.readValue((String) value, Person.class);
}
 
Example 6
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 7
Source File: StreamListenerMessageArgumentTests.java    From spring-cloud-stream with Apache License 2.0 5 votes vote down vote up
@StreamListener(Processor.INPUT)
@SendTo(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 8
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 9
Source File: ContentTypeTckTests.java    From spring-cloud-stream with Apache License 2.0 5 votes vote down vote up
@ServiceActivator(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public Message<String> echo(Message<String> value) throws Exception {
	ObjectMapper mapper = new ObjectMapper();
	Person person = mapper.readValue(value.getPayload(), Person.class);
	return MessageBuilder.withPayload(person.toString())
			.setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN)
			.build();
}
 
Example 10
Source File: ContentTypeTckTests.java    From spring-cloud-stream with Apache License 2.0 4 votes vote down vote up
@StreamListener(Processor.INPUT)
@SendTo(Processor.OUTPUT)
public Message<?> echo(Object value) throws Exception {
	return MessageBuilder.withPayload(value.toString())
			.setHeader("contentType", new MimeType("text", "plain")).build();
}
 
Example 11
Source File: FilterProcessorConfiguration.java    From spring-cloud-stream-app-starters with Apache License 2.0 4 votes vote down vote up
@Filter(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public boolean filter(Message<?> message) {
	return this.properties.getExpression().getValue(message, Boolean.class);
}
 
Example 12
Source File: AccountApplication.java    From Mastering-Spring-Cloud with MIT License 4 votes vote down vote up
@StreamListener(Processor.INPUT)
public void receiveOrder(Order order) throws JsonProcessingException {
	LOGGER.info("Order received: {}", mapper.writeValueAsString(order));
	service.process(order);
}
 
Example 13
Source File: ContentTypeTckTests.java    From spring-cloud-stream with Apache License 2.0 4 votes vote down vote up
@StreamListener(Processor.INPUT)
@SendTo(Processor.OUTPUT)
public Message<?> echo(Object value) throws Exception {
	return MessageBuilder.withPayload(value.toString())
			.setHeader("contentType", new MimeType("text")).build();
}
 
Example 14
Source File: StreamListenerHandlerMethodTests.java    From spring-cloud-stream with Apache License 2.0 4 votes vote down vote up
@StreamListener(value = Processor.INPUT, copyHeaders = "${foo.bar:false}")
@SendTo(Processor.OUTPUT)
public String receive(String received) {
	return received.toUpperCase();
}
 
Example 15
Source File: GroovyTransformProcessorConfiguration.java    From spring-cloud-stream-app-starters with Apache License 2.0 4 votes vote down vote up
@Bean
@Transformer(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public MessageProcessor<?> transformer() {
	return new GroovyScriptExecutingMessageProcessor(
			new ResourceScriptSource(properties.getScript()), scriptVariableGenerator);
}
 
Example 16
Source File: StreamListenerDuplicateMappingTests.java    From spring-cloud-stream with Apache License 2.0 4 votes vote down vote up
@StreamListener(Processor.INPUT)
@SendTo(Processor.OUTPUT)
public String receiveDuplicateMapping(Message<String> fooMessage) {
	return null;
}
 
Example 17
Source File: StreamListenerMethodWithReturnValueTests.java    From spring-cloud-stream with Apache License 2.0 4 votes vote down vote up
@StreamListener(Processor.INPUT)
@SendTo(Processor.OUTPUT)
public String receive(StreamListenerTestUtils.FooPojo fooPojo) {
	this.receivedPojos.add(fooPojo);
	return fooPojo.getFoo();
}
 
Example 18
Source File: ContentTypeTckTests.java    From spring-cloud-stream with Apache License 2.0 4 votes vote down vote up
@ServiceActivator(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public Object echo(Object value) throws Exception {
	System.out.println(value);
	return value;
}
 
Example 19
Source File: ContentTypeTckTests.java    From spring-cloud-stream with Apache License 2.0 4 votes vote down vote up
@StreamListener(Processor.INPUT)
@SendTo("internalChannel")
public String handleA(Person value) {
	return "{\"name\":\"" + value.getName().toUpperCase() + "\"}";
}
 
Example 20
Source File: ContentTypeTckTests.java    From spring-cloud-stream with Apache License 2.0 4 votes vote down vote up
@ServiceActivator(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public Object echo(Message<?> value) throws Exception {
	System.out.println(value.getPayload());
	return value.getPayload();
}