Reputation: 5906
I running the application https://github.com/spring-cloud/spring-cloud-stream-samples/tree/master/stream-listener , met some errors ,why ?
Sending value: hi of type class demo.domain.Foo
2016-04-07 19:19:50.811 ERROR 76016 --- [hannel-adapter1] o.s.c.s.b.r.RedisMessageChannelBinder$2 : Failed to deliver message; retries exhausted; message sent to queue 'ERRORS:testtock.anonymous.61fc01c4-17a1-46b5-9579-286413dc45e0'
org.springframework.messaging.converter.MessageConversionException: No converter found to convert to class demo.domain.Bar, message=GenericMessage [payload=hi, headers={contentType=text/plain, id=72274970-5e79-a8ef-d3f1-fcd4ede2fa55, timestamp=1460027990799}]
at org.springframework.messaging.handler.annotation.support.PayloadArgumentResolver.resolveArgument(PayloadArgumentResolver.java:118) ~[spring-messaging-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
at org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:98) ~[spring-messaging-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:138) ~[spring-messaging-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:107) ~[spring-messaging-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
at org.springframework.cloud.stream.binding.StreamListenerAnnotationBeanPostProcessor$StreamListenerMessageHandler.handleRequestMessage(StreamListenerAnnotationBeanPostProcessor.java:192) ~[spring-cloud-stream-1.0.0.RC1.jar!/:1.0.0.RC1]
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:99) ~[spring-integration-core-4.2.5.RELEASE.jar!/:na]
The whole code and error details is in https://github.com/keryhu/spring-stream-transform-converter
Upvotes: 0
Views: 533
Reputation: 4179
I think the problem is that you try to send String as the message while you expect that to be converted to Bar. In your context, you only have FooToBarConverter
, hence you would need to send Foo
as the message payload in your source.
If your source looks like this:
return new MessageSource<Foo>() {
public Message<Foo> receive() {
System.out.println("******************");
System.out.println("At the Source");
System.out.println("******************");
Foo foo = new Foo();
foo.setValue("hi");
System.out.println("Sending value: " + foo.getValue() + " of type " + foo.getClass());
return MessageBuilder.withPayload(foo).build();
}
};
then that would work. Otherwise, you would need a converter that converts String
to Bar
.
Upvotes: 1
Reputation: 4179
It looks like your ConverterConfig
doesn't get picked up. In the samples, all the configuration classes are in the same package as that of the @SpringBootApplication
main class TypeConversionApplication.java
so that ComponentScan is done for all the classes in that package. You need to make sure the converter is in the context of your Sink application.
Upvotes: 0