Meta annotations won't work in this context since the @RabbitListener
bindings
property is a QueueBinding[]
and annotations don't have inheritance.
To implement it would need a customized RabbitListenerAnnotationBeanPostProcessor
but, since it can't be done in a generic way, I don't think it can be part of the framework, at least in the way you describe.
We might be able to reduce the boilerplate in some other way though; feel free to open a JIRA issue and we can take a look at what might be possible.
EDIT
After receiving the JIRA Issue I thought about it some more and you can achieve your desired results using a custom listener annotation, meta-annotated with @RabbitListener
...
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@RabbitListener(bindings = @QueueBinding(
value = @Queue,
exchange = @Exchange(value = "test.metaFanout", type = ExchangeTypes.FANOUT, autoDelete = "true")))
public @interface MyAnonFanoutListener {
}
public static class MetaListener {
@MyAnonFanoutListener
public void handle1(String foo) {
...
}
@MyAnonFanoutListener
public void handle2(String foo) {
...
}
}
Each listener will get an anonymous, auto-delete, queue bound to the fanout exchange.