Johan
Johan

Reputation: 40530

Convert a org.springframework.amqp.support.converter.MessageConverter to a org.springframework.messaging.converter.MessageConverter

I have a custom org.springframework.amqp.support.converter.MessageConverter written to be used by spring-amqp but now we're moving to spring cloud stream which uses another MessageConverter (org.springframework.messaging.converter.MessageConverter).

So is there a way to convert from a Spring AMQP MessageConverter (org.springframework.amqp.support.converter.MessageConverter) to a Spring Cloud Stream MessageConverter (org.springframework.messaging.converter.MessageConverter)?

If not, is there a way to convert between a org.springframework.amqp.core.Message to a org.springframework.messaging.Message and vice versa so that I can reuse my customer message converter written for Spring AMQP?

Upvotes: 1

Views: 523

Answers (1)

Gary Russell
Gary Russell

Reputation: 174604

What is the nature of your customization?

In Spring Cloud Stream, on the consumer side, the AMQP message is already converted to a messaging Message<?> before the converters are consulted to convert the byte[] payload (the AMQP message body()) to the required type.

MessageProperties are mapped to Message<?> headers.

On the outbound side, the converter must create a byte[] payload.

Converters in SCSt are independent of the transports (RabbitMQ, Kafka etc) so you can change the binder without rewriting any code.

So you will need to port your logic to a messaging converter.

Upvotes: 2

Related Questions