Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usenative encoding ingored in FunctionInvoker #1536

Closed
kavukcutolga opened this issue Nov 22, 2018 · 3 comments
Closed

Usenative encoding ingored in FunctionInvoker #1536

kavukcutolga opened this issue Nov 22, 2018 · 3 comments
Assignees
Milestone

Comments

@kavukcutolga
Copy link
Contributor

Spring cloud stream function invoker by default using message converters after getting output from function.

org.springframework.cloud.stream.function.FunctionInvoker*:

return input.concatMap(message -> {  
   return Flux.just(message)  
            .doOnNext(originalMessageRef::set)  
            .map(this::resolveArgument)  
            .transform(this.userFunction::apply)  
            .retryBackoff(consumerProperties.getMaxAttempts(),  
  Duration.ofMillis(consumerProperties.getBackOffInitialInterval()),  
  Duration.ofMillis(consumerProperties.getBackOffMaxInterval()))  
            .onErrorResume(e -> {  
               onError(e, originalMessageRef.get());  
 return Mono.empty();  
  });  
}).log().map(resultMessage -> toMessage(resultMessage, originalMessageRef.get())); //
	@SuppressWarnings("unchecked")
	private <T> Message<O> toMessage(T value, Message<I> originalMessage) {
		if (logger.isDebugEnabled()) {
			logger.debug("Converting result back to message using the original message: " + originalMessage);
		}
		Message<O> returnMessage = (Message<O>)
				(value instanceof Message
						? value
						: this.messageConverter.toMessage(value, originalMessage.getHeaders(), this.outputClass));
		if (returnMessage == null) {
			if (value.getClass().isAssignableFrom(this.outputClass)) {
				returnMessage = (Message<O>) MessageBuilder.withPayload(value).copyHeaders(originalMessage.getHeaders()).removeHeader(MessageHeaders.CONTENT_TYPE).build();
			}
		}
		Assert.notNull(returnMessage, "Failed to convert result value '" + value + "' to message.");
		return returnMessage;
	}

But when useNativeEncoding set to true seems like result should be returned directly ? Any ideas about this, do you think this should be patched ?

output:  
  destination: events  
  producer:  
    useNativeEncoding: true
kavukcutolga pushed a commit to kavukcutolga/spring-cloud-stream that referenced this issue Nov 22, 2018
@olegz olegz self-assigned this Nov 22, 2018
@olegz olegz added this to the 2.1.0.RELEASE milestone Nov 22, 2018
@olegz
Copy link
Contributor

olegz commented Nov 22, 2018

@kavukcutolga Thank you for your contribution. Will review

@kavukcutolga
Copy link
Contributor Author

@olegz thanks I am working on test cases waiting for your feedback

kavukcutolga pushed a commit to kavukcutolga/spring-cloud-stream that referenced this issue Nov 22, 2018
kavukcutolga pushed a commit to kavukcutolga/spring-cloud-stream that referenced this issue Nov 22, 2018
kavukcutolga pushed a commit to kavukcutolga/spring-cloud-stream that referenced this issue Nov 22, 2018
kavukcutolga pushed a commit to kavukcutolga/spring-cloud-stream that referenced this issue Nov 22, 2018
kavukcutolga pushed a commit to kavukcutolga/spring-cloud-stream that referenced this issue Nov 22, 2018
kavukcutolga pushed a commit to kavukcutolga/spring-cloud-stream that referenced this issue Nov 22, 2018
kavukcutolga pushed a commit to kavukcutolga/spring-cloud-stream that referenced this issue Nov 22, 2018
@kavukcutolga
Copy link
Contributor Author

@olegz just raised a complete PR #1538.

olegz added a commit to olegz/spring-cloud-stream that referenced this issue Nov 26, 2018
@olegz olegz modified the milestones: 2.1.0.RELEASE, 2.1.0.RC3 Dec 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants