user634545
user634545

Reputation: 9419

Spring RabbitMq - Apply custom payload converter

How do I apply a custom payloadConverter in MessagingMessageConverter. It defaults to the SimpleMessageConverter class.

I can easily apply a messageConverter onto the rabbitTemplate, but it only affects the outgoing message.

The MessagingMessageConverter belongs to the MessagingMessageListenerAdapter.

Do I need to create a containerFactory in order to apply a payloadConverter?

Upvotes: 0

Views: 339

Answers (1)

Gary Russell
Gary Russell

Reputation: 174749

Yes, you set the converter on the container factory; you can either define your own bean or modify the one created by Boot. I assume you are using boot because otherwise you would have already had to define a factory.

@Component
class ContainerCustomizer {

    public ContainerCustomizer(AbstractRabbitListenerContainerFactory<?> factory) {
        factory.setMessageConverter(...);
    }

}

Upvotes: 1

Related Questions