Closed kabir closed 3 years ago
I believe the problem is in StreamTransformerMediator.processMethodConsumingAPublisherOfPayload() for this particular case and probably also will be in processMethodConsumingAPublisherBuilderOfPayload().
That is where the extra wrapping happens. I think it needs to take into account whether the generic MediatorConfigurationSupport.returnTypeAssignable is a Message or not.
You can't mix payloads and messages. Such a signature is not valid: Publisher<Message<Double>>generate(Publisher<Double> messages)
, it needs to be Publisher<Message<Double>> generate(Publisher<Message<Double>> messages)
.
I'm preparing a PR that detects and reports invalid signatures.
I noticed when updating the WildFly quickstart that the KafkaProducer gets confused about what the payload is when PublisherBuilder.map() has been used to create a message from a stream of the payloads.
I have modified the SR RM quickstart to showcase the problem here. https://github.com/smallrye/smallrye-reactive-messaging/compare/main...kabir:publisher-with-message-problem?expand=1#diff-db6074d3260024cab0f3ac87e05a6b1f4c5889f07e181960b2d08fbc1ab4d26c (the first commit is me deleting a bunch of stuff to avoid wiring errors, and adjusting the class path to be able to run it)
Essentially I have changed
to
When I do it this way, I get errors as the following
So essentially it seems to be wanting to serialise the whole Message with the value serializer, rather than just the payload when doing it this way.
I tried a few other things and they work fine (the source method is the same as in the previous example). e.g:
Also this slightly pointless one
It fails again if I put the RSO stuff in an earlier method
If I change this last example to
Then, I get the classcast exception when calling the Message.of() method.
Poking a bit further in the last method, I can see that the message is double wrapped.
I double checked the previous method, to see if what it receives is actually just the Double payload and it is
So it seems that somehow when using RSO to process the streams and create Message instances that these get double-wrapped.