-
Notifications
You must be signed in to change notification settings - Fork 643
Description
In what version(s) of Spring AMQP are you seeing this issue?
For example:
3.2.4
Describe the bug
Example uses CBORMapper from jackson-dataformat-cbor
To Reproduce
- Use
RabbitTemplate#convertAndSend()
to serialize an object and send it to a queue - Use
@RabbitListener
to read message from queue and deserialize to object
Expected behavior
Serializing and sending works.
Deserializing does not work because convertBytesToObject
converts the payload to UTF-8 string before handing it to the ObjectMapper, causing Can not create parser for non-byte-based source
.
I could get deserialization to work if I add a ;charset=ascii
to the MimeType, as that causes the raw payload to be handed to the ObjectMapper. Unfortunately this hack causes serialization to fail, because it now calls ObjectMapper#writeValueAsString
which is not supported for CBOR.
This is basically asking for it to work out of the box, or being able to override convertBytesToObject
(currently private) and a new method convertObjectToBytes
(so that I don't have to override and copy the contents of createMessage
)
Sample
public class CborMessageConverter extends AbstractJackson2MessageConverter {
public CborMessageConverter() {
super(new CBORMapper(), MimeTypeUtils.parseMimeType("application/cbor"));
}
}