I currently have my rabbit listener annotation set as:
@RabbitListener(queues = "my-queue")
Is it not possible to pull in the queue name from my yaml file. The reason I want to do this, is so that I can change my queue to a test queue for my integration test, simply by changing the queue name in the yaml file. It appears the annotation must accept a constant string, is there a way round this? Thanks,
Yes, it is called properties place holder
and can be done like this:
@RabbitListener(queues = "${myQueue.property}")
Where that myQueue.property
is exactly declared in your yaml.
https://docs.spring.io/spring-amqp/docs/1.7.3.RELEASE/reference/html/_reference.html#async-annotation-driven
The argument name, value, and type can be property placeholders (${...}) or SpEL expressions (#{...}). The name must resolve to a String; the expression for type must resolve to a Class or the fully-qualified name of a class. The value must resolve to something that can be converted by the DefaultConversionService to the type (such as the x-message-ttl in the above example).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With