Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose method for declaring multiple Declarable objects [AMQP-842] #2392

Open
spring-operator opened this issue Nov 21, 2018 · 4 comments
Open

Comments

@spring-operator
Copy link
Contributor

Alen Turkovic opened AMQP-842 and commented

org.springframework.amqp.rabbit.core.RabbitAdmin already has a method for declaring multiple queues but exposes a method for declaring a single one: RabbitAdmin#declareQueue(Queue)

The same goes for Queue, Exchange and Binding.

Expose methods for declaring multiple of these Declarable objects.

I would submit a PR myself, but I am not certain what the best responses and exception handling for these cases would be...


No further details from AMQP-842

@spring-operator
Copy link
Contributor Author

Gary Russell commented

Alen Turkovic Starting with version 2.1, you can add Declarables @Beans which are wrappers for collections of Declarable.

The admin will automatically detect these beans in the application context and automatically declare them for you.

But, I guess you are asking for programmatic methods declareQueues(Queue... queues), correct?

@spring-operator
Copy link
Contributor Author

Gary Russell commented

In the meantime, it would be easy to subclass the admin...

public class ExtendedAdmin extends RabbitAdmin {

	public ExtendedAdmin(ConnectionFactory connectionFactory) {
		super(connectionFactory);
	}

	public Collection<String> declareQueues(Queue... queues) {
		return Arrays.stream(queues)
			.map(q -> declareQueue(q))
			.collect(Collectors.toList());
	}

}

But, as you say, the real issue is how to handle exceptions - continue or abort the entire operation.

@spring-operator
Copy link
Contributor Author

Alen Turkovic commented

Yes, I was thinking about using the programmatic methods since I have some additional logic, I am already using the @Beans, thanks for the tip.

Sure, subclassing is fine, I was just thinking if exposing these methods would be ok since they are already implemented.

is there a reason they are not exposed so they can be used the same way the initialize() method uses them to create Declarables?

@spring-operator
Copy link
Contributor Author

Gary Russell commented

They are private because they have to be executed within the scope of a RabbitTemplate.execute() callback so that we have access to a channel.

I am not objecting to adding new methods, though. We just need to give some thought about exception handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant