例如:
@RabbitHandler
@RabbitListener(bindings = @QueueBinding(
value = @Queue(value = RabbitMqConstant.QUEUE_MESSAGE_NOTIFICATION_ANDROID_PUSHED, durable = "true", autoDelete = "false"),
exchange = @Exchange(value = RabbitMqConstant.EXCHANGE_DIRECT_NOTIFICATION_ANDROID, type = ExchangeTypes.DIRECT)), ackMode = "MANUAL")
public void androidPushByAccount(NotificationDto notificationDto, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag, Channel channel) throws Exception {
}
我想给消费者监听器批量添加参数,像这样:
arguments = {
@Argument(name = "x-dead-letter-exchange", value = RabbitConfig.DEAD_DIRECT_EXCHANGE),
@Argument(name = "x-dead-letter-routing-key", value = RabbitConfig.DEAD_LETTER_ROUTING_KEY),
@Argument(name = "x-max-length", value = RabbitConfig.MAX_LENGTH, type = "java.lang.Integer"),
@Argument(name = "x-message-ttl", value = RabbitConfig.MESSAGE_TTL, type = "java.lang.Integer")
}
我像这样创建了 RabbitListenerAnnotationBeanPostProcessor:
@Component
public class TbtRabbitListenerAnnotationBeanPostProcessor implements BeanPostProcessor {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
Class<?> targetClass = AopUtils.getTargetClass(bean);
Collection<RabbitListener> classLevelListeners = findListenerAnnotations(targetClass);
classLevelListeners.forEach(rabbitListener -> {
for(QueueBinding queueBinding: rabbitListener.bindings()) {
//how to modify arguments value ?????
queueBinding.value().arguments()
}
});
return BeanPostProcessor.super.postProcessBeforeInitialization(bean, beanName);
}
}
如何在方法 postProcessBeforeInitialization 中修改参数值