1
我有@RabbitListener(id="example", queues={"a", "b"})
偵聽器,我複製粘貼在我的代碼中的多個位置通過不同的模塊。我想創造一個別名,如:我可以創建Spring RabbitListener別名嗎?
@Target({ ElementType.TYPE, ElementType.METHOD, ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)
@MessageMapping
@Documented
public @interface MyRabbitListener {
@AliasFor(annotation = RabbitListener.class)
String id() default "example";
@AliasFor(annotation = RabbitListener.class)
String containerFactory() default "";
@AliasFor(annotation = RabbitListener.class)
String[] queues() default {"a", "b"};
@AliasFor(annotation = RabbitListener.class)
boolean exclusive() default false;
@AliasFor(annotation = RabbitListener.class)
String priority() default "";
@AliasFor(annotation = RabbitListener.class)
String admin() default "";
@AliasFor(annotation = RabbitListener.class)
QueueBinding[] bindings() default {};
@AliasFor(annotation = RabbitListener.class)
String group() default "";
}
然後,我只是用我的方法@MyRabbitListener
,但它不工作,因爲我想有不spring-amqp
模塊別名支持呢。有什麼方法可以註冊我的別名嗎?