Skip to content

byte[] received when using @RabbitListener with Batching #2890

@artembilan

Description

@artembilan

Discussed in #2889

Originally posted by arths31 November 6, 2024
Hello,
I'm having an issue when using @RabbitListener with batching enabled.

Batching works fine but I want to receive a list of org.springframework.amqp.core.Message and I am receiving a list of byte[] instead.

Here is the bean I use to configure the containerFactory

@Bean
    fun myFactory(configurer: SimpleRabbitListenerContainerFactoryConfigurer): SimpleRabbitListenerContainerFactory {
        val factory = SimpleRabbitListenerContainerFactory()
        factory.setConnectionFactory(connectionFactory)
        factory.setBatchListener(true)
        factory.setBatchSize(10)
        factory.setConsumerBatchEnabled(true)
        factory.setDeBatchingEnabled(false)
        factory.setReceiveTimeout(5000)
        return factory
    }

and here is where I expect to receive my messages

@RabbitListener(bindings = [
        QueueBinding(
            value = org.springframework.amqp.rabbit.annotation.Queue(name = "test", durable = "true"),
            key = ["xxx.#"],
            exchange = Exchange(name = Constants.EVENT_EXCHANGE_NAME, type = ExchangeTypes.TOPIC)
        )
    ], containerFactory = "myFactory")
    fun listen(messages: List<Message>) {
       ...
     }

messages returns a list of byte[] which contains my payloads.

I have tried switching to List<org.springframework.messaging.Message> and even a list of String just like in the following exemple but to no avail : https://docs.spring.io/spring-amqp/reference/amqp/receiving-messages/batch.html

Thank you in advance for your help

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions